|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.zfqjava.swing.cell.AbstractCellRenderer
AbstractCellRenderer
provides a abstract cell renderer,
can renderer JList
, JTable
,
JTree
.
Field Summary | |
protected static javax.swing.border.Border |
noFocusBorder
The border used when the cell has no focus. |
protected boolean |
useFocusColor
True use the focus color when the cell has focus. |
Constructor Summary | |
AbstractCellRenderer()
|
Method Summary | |
CellProvider |
getCellProvider()
Returns the cell provider to add extra info for current renderer. |
abstract java.awt.Component |
getComponent()
Returns the component for this renderer. |
java.awt.Component |
getListCellRendererComponent(javax.swing.JList list,
java.lang.Object value,
int index,
boolean isSelected,
boolean cellHasFocus)
Return a component that has been configured to display the specified value. |
java.awt.Component |
getTableCellRendererComponent(javax.swing.JTable table,
java.lang.Object value,
boolean isSelected,
boolean hasFocus,
int row,
int column)
Returns the component used for drawing the cell. |
java.awt.Component |
getTreeCellRendererComponent(javax.swing.JTree tree,
java.lang.Object value,
boolean selected,
boolean expanded,
boolean leaf,
int row,
boolean hasFocus)
Sets the value of the current tree cell to value . |
void |
setCellProvider(CellProvider provider)
Sets the cell provider to add extra info for current renderer. |
protected abstract void |
setValue(java.lang.Object value)
Sets the value for current renderer. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static javax.swing.border.Border noFocusBorder
new EmptyBorder(1, 1, 1, 1)
.protected boolean useFocusColor
TableCellRenderer
.
The default is true
.Constructor Detail |
public AbstractCellRenderer()
Method Detail |
public java.awt.Component getListCellRendererComponent(javax.swing.JList list, java.lang.Object value, int index, boolean isSelected, boolean cellHasFocus)
paint
method is then called to
"render" the cell. If it is necessary to compute the dimensions
of a list because the list cells do not have a fixed size, this method
is called to generate a component on which getPreferredSize
can be invoked.getListCellRendererComponent
in interface javax.swing.ListCellRenderer
list
- The JList we're painting.value
- The value returned by list.getModel().getElementAt(index).index
- The cells index.isSelected
- True if the specified cell was selected.cellHasFocus
- True if the specified cell has the focus.JList
,
ListSelectionModel
,
ListModel
public java.awt.Component getTableCellRendererComponent(javax.swing.JTable table, java.lang.Object value, boolean isSelected, boolean hasFocus, int row, int column)
getTableCellRendererComponent
in interface javax.swing.table.TableCellRenderer
table
- the JTable
that is asking the
renderer to draw; can be null
value
- the value of the cell to be rendered. It is
up to the specific renderer to interpret
and draw the value. For example, if
value
is the string "true", it could be rendered as a
string or it could be rendered as a check
box that is checked. null
is a
valid valueisSelected
- true if the cell is to be rendered with the
selection highlighted; otherwise falsehasFocus
- if true, render cell appropriately. For
example, put a special border on the cell, if
the cell can be edited, render in the color used
to indicate editingrow
- the row index of the cell being drawn. When
drawing the header, the value of
row
is -1column
- the column index of the cell being drawnpublic java.awt.Component getTreeCellRendererComponent(javax.swing.JTree tree, java.lang.Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus)
value
.
If selected
is true, the cell will be drawn as if
selected. If expanded
is true the node is currently
expanded and if leaf
is true the node represets a
leaf and if hasFocus
is true the node currently has
focus. tree
is the JTree
the receiver is being
configured for. Returns the Component
that the renderer
uses to draw the value.getTreeCellRendererComponent
in interface javax.swing.tree.TreeCellRenderer
Component
that the renderer uses to draw the valuepublic void setCellProvider(CellProvider provider)
provider
- the cell providergetCellProvider()
public CellProvider getCellProvider()
setCellProvider(com.zfqjava.swing.cell.CellProvider)
public abstract java.awt.Component getComponent()
protected abstract void setValue(java.lang.Object value)
value
- the value to renderer
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |