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 以降、すべての JavaBeansTM 用の長期間の格納サポートが 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 |
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWBOTTOM_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, 2013, Oracle and/or its affiliates. All rights reserved.