public class DefaultTableCellRenderer extends JLabel implements TableCellRenderer, Serializable
JTable内の個々のセルをレンダリング(表示)するための標準クラス。
実装上のノート: このクラスは標準コンポーネント・クラスのJLabelを継承しています。 ただし、JTableはそのセルのレンダリングに独自のメカニズムを採用しているため、そのセル・レンダラから多少の変更が加えられた動作を必要とします。 テーブル・クラスは単一のセル・レンダラを定義し、テーブル内のすべてのセルをレンダリングするゴム・スタンプとしてそれを使用します。つまり、最初のセルをレンダリングしたら、そのセル・レンダラのコンテンツを変更し、原点を新しい位置に移動して、それを再描画するという具合です。 標準のJLabelコンポーネントはこのような方法で使用するように設計されなかったため、セルが描画されるたびに、revalidateがトリガーされないようにする必要があります。 revalidateメッセージは他のコンポーネントが影響を受けるかどうかを判定するためにコンテナの上位階層に渡されるので、トリガーされないようにしないと、パフォーマンスが大幅に低下します。 レンダラはペイント操作の有効期間にのみ生成されるため、同様にペイント操作の階層内の移動にまつわるオーバーヘッドが生じないようにする必要もあります。 そのため、このクラスは、validate、invalidate、revalidate、repaint、およびfirePropertyChangeメソッドを何もしないようにオーバーライドし、単にパフォーマンスを向上させるためにisOpaqueメソッドをオーバーライドします。 独自のレンダラを書き込む場合は、このパフォーマンスのことを考慮してください。
警告: このクラスの直列化されたオブジェクトは、今後のSwingリリースと互換ではなくなる予定です。 現在の直列化のサポートは、短期間の格納や、同じバージョンのSwingを実行するアプリケーション間のRMIに適しています。 1.4以降、すべてのJavaBeans™用の長期間の格納サポートがjava.beansパッケージに追加されています。 XMLEncoderを参照してください。
JTable| 修飾子と型 | クラス | 説明 |
|---|---|---|
static class |
DefaultTableCellRenderer.UIResource |
UIResourceを実装するDefaultTableCellRendererのサブクラス。 |
JLabel.AccessibleJLabelJComponent.AccessibleJComponentContainer.AccessibleAWTContainerComponent.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy| 修飾子と型 | フィールド | 説明 |
|---|---|---|
protected static Border |
noFocusBorder |
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWaccessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTBOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WESTABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH| コンストラクタ | 説明 |
|---|---|
DefaultTableCellRenderer() |
デフォルトのテーブル・セル・レンダラを作成します。
|
| 修飾子と型 | メソッド | 説明 |
|---|---|---|
void |
firePropertyChange(String propertyName, boolean oldValue, boolean newValue) |
パフォーマンス上の理由でオーバーライドされます。
|
protected void |
firePropertyChange(String propertyName, Object oldValue, Object newValue) |
パフォーマンス上の理由でオーバーライドされます。
|
Component |
getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) |
デフォルトのテーブル・セル・レンダラを返します。
|
void |
invalidate() |
パフォーマンス上の理由でオーバーライドされます。
|
boolean |
isOpaque() |
パフォーマンス上の理由でオーバーライドされます。
|
void |
repaint() |
パフォーマンス上の理由でオーバーライドされます。
|
void |
repaint(long tm, int x, int y, int width, int height) |
パフォーマンス上の理由でオーバーライドされます。
|
void |
repaint(Rectangle r) |
パフォーマンス上の理由でオーバーライドされます。
|
void |
revalidate() |
パフォーマンス上の理由でオーバーライドされます。
|
void |
setBackground(Color c) |
JComponent.setBackgroundをオーバーライドして、未選択のバックグラウンド・カラーに指定された色を割り当てます。 |
void |
setForeground(Color c) |
JComponent.setForegroundをオーバーライドして、未選択のフォアグラウンド・カラーに指定された色を割り当てます。 |
protected void |
setValue(Object value) |
レンダリングされるセルの
Stringオブジェクトをvalueに設定します。 |
void |
updateUI() |
Look & Feel (L&F)が変更されたという
UIManagerからの通知です。 |
void |
validate() |
パフォーマンス上の理由でオーバーライドされます。
|
checkHorizontalKey, checkVerticalKey, getAccessibleContext, getDisabledIcon, getDisplayedMnemonic, getDisplayedMnemonicIndex, getHorizontalAlignment, getHorizontalTextPosition, getIcon, getIconTextGap, getLabelFor, getText, getUI, getUIClassID, getVerticalAlignment, getVerticalTextPosition, imageUpdate, paramString, setDisabledIcon, setDisplayedMnemonic, setDisplayedMnemonic, setDisplayedMnemonicIndex, setHorizontalAlignment, setHorizontalTextPosition, setIcon, setIconTextGap, setLabelFor, setText, setUI, setVerticalAlignment, setVerticalTextPositionaddAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateadd, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validateTreeaction, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycleprotected static Border noFocusBorder
public void setForeground(Color c)
JComponent.setForegroundをオーバーライドして、未選択のフォアグラウンド・カラーに指定された色を割り当てます。setForeground、クラスJComponentc - この値のフォアグラウンド・カラーを設定するComponent.getForeground()public void setBackground(Color c)
JComponent.setBackgroundをオーバーライドして、未選択のバックグラウンド・カラーに指定された色を割り当てます。setBackground、クラスJComponentc - この値のバックグラウンド・カラーを設定するComponent.getBackground(), JComponent.setOpaque(boolean)public void updateUI()
UIManagerからの通知です。 現在のUIオブジェクトをUIManagerの最新バージョンに置き換えます。 updateUI、クラスJLabelJComponent.updateUI()public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
印刷操作中は、印刷結果に選択範囲やフォーカスが表示されるのを防ぐため、isSelectedおよびhasFocusの値をfalseにしてこのメソッドを呼び出します。 テーブルを印刷するかどうかに基づいてその他のカスタマイズを行うには、JComponent.isPaintingForPrint()の戻り値を確認します。
getTableCellRendererComponent、インタフェースTableCellRenderertable - JTablevalue - [row, column]のセルに割り当てる値isSelected - セルが選択されている場合はtruehasFocus - フォーカスがある場合はtruerow - レンダリングされるセルの行column - レンダリングされるセルの列JComponent.isPaintingForPrint()public boolean isOpaque()
isOpaque、クラスJComponentJComponent.setOpaque(boolean)public void invalidate()
invalidate、クラスContainerContainer.validate(), Container.layout(), LayoutManager2public void validate()
public void revalidate()
public void repaint(long tm,
int x,
int y,
int width,
int height)
repaint、クラスJComponenttm - このパラメータは使用されないx - ダーティ・リージョンのx座標y - ダーティ・リージョンのy座標width - ダーティ・リージョンの幅height - ダーティ・リージョンの高さJComponent.isPaintingOrigin(), Component.isShowing(), RepaintManager.addDirtyRegion(javax.swing.JComponent, int, int, int, int)public void repaint(Rectangle r)
repaint、クラスJComponentr - ダーティ・リージョンを含むRectangleJComponent.isPaintingOrigin(), Component.isShowing(), RepaintManager.addDirtyRegion(javax.swing.JComponent, int, int, int, int)public void repaint()
repaint、クラスComponentComponent.update(Graphics)protected void firePropertyChange(String propertyName, Object oldValue, Object newValue)
firePropertyChange、クラスComponentpropertyName - 値が変更されたプロパティoldValue - プロパティの以前の値newValue - プロパティの新しい値public void firePropertyChange(String propertyName, boolean oldValue, boolean newValue)
firePropertyChange、クラスJComponentpropertyName - 値が変更されたプロパティoldValue - プロパティの以前の値newValue - プロパティの新しい値protected void setValue(Object value)
Stringオブジェクトをvalueに設定します。value - このセルの文字列の値。値がnullの場合は、テキスト値を空の文字列にするJLabel.setText(java.lang.String) バグまたは機能を送信
詳細なAPIリファレンスおよび開発者ドキュメントについては、Java SEのドキュメントを参照してください。 そのドキュメントには、概念的な概要、用語の定義、回避方法、有効なコード例などの、開発者を対象にしたより詳細な説明が含まれています。
Copyright © 1993, 2025, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Documentation Redistribution Policyも参照してください。