|
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.JLabel
javax.swing.table.DefaultTableCellRenderer
com.sciapp.renderers.DefaultRenderer
public class DefaultRenderer
A TableCellRenderer which is common to all renderers in the com.sciapp.renderers
package.
This renderer paints alternate rows of a JTable with different color and also adds spaces at the
end of each cell, so that to improve the presentation of the table.
These two options can be controlled via the setEvenColor
, setOddColor
and
setSpacing
respectively.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class javax.swing.table.DefaultTableCellRenderer |
---|
DefaultTableCellRenderer.UIResource |
Nested classes/interfaces inherited from class javax.swing.JLabel |
---|
JLabel.AccessibleJLabel |
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 Color |
evenColor
the background color for even rows |
protected Color |
oddColor
the background color for odd rows |
protected String |
space
a string that holds the number of spaces |
protected boolean |
spacing
boolean flag that indicates if spaces are added at the end of each cell |
Fields inherited from class javax.swing.table.DefaultTableCellRenderer |
---|
noFocusBorder |
Fields inherited from class javax.swing.JLabel |
---|
labelFor |
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 javax.swing.SwingConstants |
---|
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
DefaultRenderer()
Constructs a default DefaultRenderer that does not paint alternate rows of the table and that adds 3 spaces at the end of each cell. |
Method Summary | |
---|---|
Color |
getEvenColor()
Returns the color used to paint the even rows of the table. |
Color |
getOddColor()
Returns the color used to paint the odd rows of the table. |
boolean |
getSpacing()
Determines whether the renderer will add spaces to the end of each cell. |
Component |
getTableCellRendererComponent(JTable table,
Object value,
boolean isSelected,
boolean hasFocus,
int row,
int column)
Returns the component used for drawing the cell. |
void |
setEvenColor(Color evenColor)
Sets the color for painting the even rows of the table. |
void |
setOddColor(Color oddColor)
Sets the color for painting the odd rows of the table. |
void |
setSpaces(int numSpaces)
Sets the number of spaces to add at the end of each cell. |
void |
setSpacing(boolean spacing)
Tells the renderer whether to add spaces at the end of each cell. |
void |
setText(String text)
Defines the single line of text this renderer will display. |
Methods inherited from class javax.swing.table.DefaultTableCellRenderer |
---|
firePropertyChange, firePropertyChange, isOpaque, repaint, repaint, revalidate, setBackground, setForeground, setValue, updateUI, validate |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected Color oddColor
protected Color evenColor
protected boolean spacing
protected String space
Constructor Detail |
---|
public DefaultRenderer()
Method Detail |
---|
public Color getEvenColor()
public Color getOddColor()
public boolean getSpacing()
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
getTableCellRendererComponent
in interface TableCellRenderer
getTableCellRendererComponent
in class DefaultTableCellRenderer
table
- the JTable
value
- the value to assign to the cell at
[row, column]
isSelected
- true if cell is selectedhasFocus
- true if cell has focusrow
- the row of the cell to rendercolumn
- the column of the cell to render
public void setEvenColor(Color evenColor)
evenColor
- the even row colorpublic void setOddColor(Color oddColor)
oddColor
- the odd row colorpublic void setSpaces(int numSpaces)
numSpaces
- the number of spaces.public void setSpacing(boolean spacing)
spacing
- true if spacing is usedpublic void setText(String text)
setText
in class JLabel
text
- the string to display.JLabel.setVerticalTextPosition(int)
,
JLabel.setHorizontalTextPosition(int)
,
JLabel.setIcon(javax.swing.Icon)
|
Copyright © 2005 Scientific Applications. All Rights Reserved. | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |