JTable
.
Implementation Note:
This class inherits from JLabel
, a standard component class.
However JTable
employs a unique mechanism for rendering
its cells and therefore requires some slightly modified behavior
from its cell renderer.
The table class defines a single cell renderer and uses it as a
as a rubber-stamp for rendering all cells in the table;
it renders the first cell,
changes the contents of that cell renderer,
shifts the origin to the new location, re-draws it, and so on.
The standard JLabel
component was not
designed to be used this way and we want to avoid
triggering a revalidate
each time the
cell is drawn. This would greatly decrease performance because the
revalidate
message would be
passed up the hierarchy of the container to determine whether any other
components would be affected.
As the renderer is only parented for the lifetime of a painting operation
we similarly want to avoid the overhead associated with walking the
hierarchy for painting operations.
So this class
overrides the validate
, invalidate
,
revalidate
, repaint
, and
firePropertyChange
methods to be
no-ops and override the isOpaque
method solely to improve
performance. If you write your own renderer,
please keep this performance consideration in mind.
Warning
Serialized objects of this class will not be compatible with
future Swing releases. The current serialization support is
appropriate for short term storage or RMI between applications running
the same version of Swing. As of 1.4, support for long term storage
of all JavaBeans
has been added to the java.beans
package.
Please see java.
.
JTable
Modifier and Type | Class and Description |
---|---|
public static class | DefaultTableCellRenderer.
A subclass of |
Modifier and Type | Field and Description |
---|---|
private static final Border | |
protected static Border | noFocusBorder
A border without focus. |
private static final Border | SAFE_NO_FOCUS_BORDER
An empty |
private Color | |
private Color |
Access | Constructor and Description |
---|---|
public |
Modifier and Type | Method and Description |
---|---|
protected void | firePropertyChange(String
the property whose value has changed propertyName, Object the property's previous value oldValue, Object the property's new value newValue)Overrides java. |
public void | firePropertyChange(String
the property whose value has changed propertyName, boolean the property's previous value oldValue, boolean the property's new value newValue)Overrides javax. |
private Border | |
public Component | Returns: the default table cell rendererthe table, Object JTable the value to assign to the cell at
value, boolean [row, column] true if cell is selected isSelected, boolean true if cell has focus hasFocus, int the row of the cell to render row, int the column of the cell to render column)Implements javax. |
public void | |
public boolean | |
public void | repaint(long
this parameter is not used tm, int the x value of the dirty region x, int the y value of the dirty region y, int the width of the dirty region width, int the height of the dirty region height)Overrides javax. |
public void | repaint(Rectangle
a r)Rectangle containing the dirty regionOverrides javax. |
public void | |
public void | |
public void | setBackground(Color
set the background color to this value c)Overrides javax. JComponent.setBackground to assign
the unselected-background color to the specified color.
|
public void | setForeground(Color
set the foreground color to this value c)Overrides javax. JComponent.setForeground to assign
the unselected-foreground color to the specified color.
|
protected void | |
public void | updateUI()
Overrides javax. UIManager that the look and feel
[L&F] has changed.
|
public void |
DEFAULT_NO_FOCUS_BORDER | back to summary |
---|---|
private static final Border DEFAULT_NO_FOCUS_BORDER |
noFocusBorder | back to summary |
---|---|
protected static Border noFocusBorder A border without focus. |
SAFE_NO_FOCUS_BORDER | back to summary |
---|---|
private static final Border SAFE_NO_FOCUS_BORDER An empty |
unselectedBackground | back to summary |
---|---|
private Color unselectedBackground |
unselectedForeground | back to summary |
---|---|
private Color unselectedForeground |
DefaultTableCellRenderer | back to summary |
---|---|
public DefaultTableCellRenderer() Creates a default table cell renderer. |
firePropertyChange | back to summary |
---|---|
protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) Overrides java. Overridden for performance reasons. See the Implementation Note for more information.
|
firePropertyChange | back to summary |
---|---|
public void firePropertyChange(String propertyName, boolean oldValue, boolean newValue) Overrides javax. Overridden for performance reasons. See the Implementation Note for more information.
|
getNoFocusBorder | back to summary |
---|---|
private Border getNoFocusBorder()
|
getTableCellRendererComponent | back to summary |
---|---|
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) Implements javax. Returns the default table cell renderer.
During a printing operation, this method will be called with
|
invalidate | back to summary |
---|---|
public void invalidate() Overrides java. Overridden for performance reasons. See the Implementation Note for more information.
|
isOpaque | back to summary |
---|---|
public boolean isOpaque() Overrides javax. Overridden for performance reasons. See the Implementation Note for more information.
|
repaint | back to summary |
---|---|
public void repaint(long tm, int x, int y, int width, int height) Overrides javax. Overridden for performance reasons. See the Implementation Note for more information.
|
repaint | back to summary |
---|---|
public void repaint(Rectangle r) Overrides javax. Overridden for performance reasons. See the Implementation Note for more information.
|
repaint | back to summary |
---|---|
public void repaint() Overrides java. Overridden for performance reasons. See the Implementation Note for more information.
|
revalidate | back to summary |
---|---|
public void revalidate() Overrides javax. Overridden for performance reasons. See the Implementation Note for more information. |
setBackground | back to summary |
---|---|
public void setBackground(Color c) Overrides javax. Overrides
|
setForeground | back to summary |
---|---|
public void setForeground(Color c) Overrides javax. Overrides
|
setValue | back to summary |
---|---|
protected void setValue(Object value) Sets the
|
updateUI | back to summary |
---|---|
public void updateUI() Overrides javax. Notification from the
|
validate | back to summary |
---|---|
public void validate() Overrides java. Overridden for performance reasons. See the Implementation Note for more information. |
DefaultTableCellRenderer
that
implements UIResource
.
DefaultTableCellRenderer
doesn't implement
UIResource
directly so that applications can safely override the
cellRenderer
property with
DefaultTableCellRenderer
subclasses.Warning
Serialized objects of this class will not be compatible with
future Swing releases. The current serialization support is
appropriate for short term storage or RMI between applications running
the same version of Swing. As of 1.4, support for long term storage
of all JavaBeans
has been added to the java.beans
package.
Please see java.
.
Access | Constructor and Description |
---|---|
public |
UIResource | back to summary |
---|---|
public UIResource() Constructs a |