|
Copyright © 2005 Scientific Applications. All Rights Reserved. | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.table.JTableHeader
com.sciapp.table.JTableRowHeader
public class JTableRowHeader
JTableRowHeader represents a vertical table header, that can be used as the row header of a JTable. An instance of this class is created and employed by AdvancedJTable. JTableRowHeader uses a TableColumnModel to manage its cells. Each cell in the header has the same column width, whereas the row height is determined by the row height of the cell in the associative table.
The cells are rendered by a TableCellRenderer, which can be assigned by
setDefaultRowRenderer
.
By default, a DefaultRowHeaderRenderer
is set to render each cell in the header.
The value of each cell is determined by getColumnHeaderValue
.
By default, this method returns the current row number as a string.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class javax.swing.table.JTableHeader |
---|
JTableHeader.AccessibleJTableHeader |
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy |
Field Summary | |
---|---|
protected int |
columnWidth
The column width of each cell in the header. |
static int |
DEFAULT_COLUMN_WIDTH
The default column width of each row in the header. |
protected TableCellRenderer |
defaultRenderer
The renderer that is assigned to render the cells of the header. |
Fields inherited from class javax.swing.table.JTableHeader |
---|
columnModel, draggedColumn, draggedDistance, reorderingAllowed, resizingAllowed, resizingColumn, table, updateTableInRealTime |
Fields inherited from class javax.swing.JComponent |
---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
Fields inherited from class java.awt.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
JTableRowHeader(TableColumnModel cm)
Constructs a JTableRowHeader with DEFAULT_COLUMN_WIDTH as the cells' width. |
|
JTableRowHeader(TableColumnModel cm,
int columnWidth)
Constructs a JTableRowHeader with columnWidth as the cells' width. |
Method Summary | |
---|---|
protected TableCellRenderer |
createDefaultRowRenderer()
Returns the default row renderer to be used. |
protected Object |
getColumnHeaderValue(int rowIndex)
Returns the object to set as the header value for the cell at rowIndex. |
int |
getColumnWidth()
Returns the width of each cell in the row header. |
TableCellRenderer |
getDefaultRowRenderer()
Returns the default row renderer used. |
Dimension |
getPreferredSize()
If the preferredSize has been set to a
non-null value just returns it. |
protected void |
paintComponent(Graphics g)
Calls the UI delegate's paint method, if the UI delegate is non- null . |
void |
setColumnWidth(int columnWidth)
Sets the width of each cell in the row header. |
void |
setDefaultRowRenderer(TableCellRenderer defaultRenderer)
Sets the default row renderer to be used. |
void |
setTable(JTable newTable)
Sets the table associated with this header. |
void |
updateUI()
Notification from the UIManager that the look and feel
(L&F) has changed. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_COLUMN_WIDTH
protected int columnWidth
protected TableCellRenderer defaultRenderer
Constructor Detail |
---|
public JTableRowHeader(TableColumnModel cm)
public JTableRowHeader(TableColumnModel cm, int columnWidth)
Method Detail |
---|
protected TableCellRenderer createDefaultRowRenderer()
DefaultRowHeaderRenderer
is returned.
protected Object getColumnHeaderValue(int rowIndex)
You can use the following code to return a numbering scheme based on letters instead of numbers:
String columnName = "";
for (; rowIndex >= 0; rowIndex = rowIndex / 26 - 1) {
columnName = (char) ((char) (rowIndex % 26) + 'A') + columnName;
}
return columnName;
public int getColumnWidth()
public TableCellRenderer getDefaultRowRenderer()
public Dimension getPreferredSize()
preferredSize
has been set to a
non-null
value just returns it.
If the UI delegate's getPreferredSize
method returns a non null
value then return that;
otherwise defer to the component's layout manager.
getPreferredSize
in class JComponent
preferredSize
propertyJComponent.setPreferredSize(java.awt.Dimension)
,
ComponentUI
protected void paintComponent(Graphics g)
null
. We pass the delegate a copy of the
Graphics
object to protect the rest of the
paint code from irrevocable changes
(for example, Graphics.translate
).
If you override this in a subclass you should not make permanent
changes to the passed in Graphics
. For example, you
should not alter the clip Rectangle
or modify the
transform. If you need to do these operations you may find it
easier to create a new Graphics
from the passed in
Graphics
and manipulate it. Further, if you do not
invoker super's implementation you must honor the opaque property,
that is
if this component is opaque, you must completely fill in the background
in a non-opaque color. If you do not honor the opaque property you
will likely see visual artifacts.
paintComponent
in class JComponent
g
- the Graphics
object to protectJComponent.paint(java.awt.Graphics)
,
ComponentUI
public void setColumnWidth(int columnWidth)
columnWidth
- the width of each cell.public void setDefaultRowRenderer(TableCellRenderer defaultRenderer)
defaultRenderer
- the default table column renderer for this row headerpublic void setTable(JTable newTable)
setTable
in class JTableHeader
newTable
- the new tablepublic void updateUI()
javax.swing.table.JTableHeader
UIManager
that the look and feel
(L&F) has changed.
Replaces the current UI object with the latest version from the
UIManager
.
updateUI
in class JTableHeader
JComponent.updateUI()
|
Copyright © 2005 Scientific Applications. All Rights Reserved. | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |