|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectquick.dbtable.DBTableCellRenderer
cellrenders for Image, checkbox, radiobutton, date
DBTable.setCellComponent(Column, int, Hashtable),
Serialized Form| Constructor Summary | |
DBTableCellRenderer(CellComponent cc,
DBTable dBTable)
Deprecated. This constructor cannot be used directly, please use Column#setUserCellRenderer(CellComponent) |
|
DBTableCellRenderer(int cellType,
java.util.Hashtable cellValueToDisplayHash,
DBTable dBTable)
Deprecated. This constructor should not be directly used, instead use the setCellComponent method in DBTable. |
|
| Method Summary | |
java.awt.Component |
getTableCellRendererComponent(javax.swing.JTable table,
java.lang.Object value,
boolean isSelected,
boolean hasFocus,
int row,
int column)
Deprecated. |
void |
updateUI()
Deprecated. Notification from the UIManager that the L&F has changed. |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public DBTableCellRenderer(int cellType,
java.util.Hashtable cellValueToDisplayHash,
DBTable dBTable)
Currently QuickTable supports the following components
Icon, label, RadioButton, ComboBox.
Following is the mapping of cellType to the component used for rendering
IMAGE_CELL - Icon Label
CHECKBOX_CELL - checkbox
RADIOBUTTON_CELL - radioButton
COMBOBOX_CELL - Label
DATE_CELL - Label, date will be displayed in given date format
DEFAULT_CELL - Label
Its not advisable to use this class directly, try to use the setCellComponent(Column c, int cellType, Hashtable cellValueToDisplayHash) method in DBTable, because that method sets both the celleditor & cell renderer, so both will be in sync. @see DBTable#setCellComponent(Column , int , Hashtable)
If you are a experienced programmer and if you know what you are doing, you can use this.
Setting Icon Renderer
Icon renderer displays the icon corresponding to the actual cell value
set the celltype argument as Column.IMAGE_CELL
set the cellValueToDisplayHash to hashtable which contains a mapping of actual cell data to the
icon that need to be displayed
For example, lets say the database contains "A" for employee alive, "D" for employee dead and "L" for employee on Leave
and you have three gif files to represent these states alive.gif, dead.gif, leave.gif
Hashtable imageHash = new Hashtable();
imageHash.put("A",new ImageIcon(this.getClass().getResource("images/alive.gif")));
imageHash.put("D",new ImageIcon(this.getClass().getResource("images/dead.gif")));
imageHash.put("L",new ImageIcon(this.getClass().getResource("images/leave.gif")));
//Note: make sure you have the images directory in classpath
yourQuickTable.getColumn(1).setCellRenderer( new DBTableCellRenderer(Column.IMAGE_CELL, imageHash, yourQuickTable));
Checkbox renderer
checkbox renderer displayes a checkbox with the checked status corresponding to the actual cell data
set the celltype argument as Column.CHECKBOX_CELL
set the cellValueToDisplayHash to hashtable which contains a mapping of actual cell data to the
checkbox selection state
For example, lets say the database contains "A" for employee alive, "D" for employee dead
and if you want to set the checkbox selected when "A" and unselected when "D"
Hashtable checkHash = new Hashtable();
checkHash.put("A",new Boolean(true));
checkHash.put("D",new Boolean(false));
yourQuickTable.getColumn(1).setCellRenderer( new DBTableCellRenderer(Column.CHECKBOX_CELL, checkHash, yourQuickTable));
radiobutton renderer
radiobutton renderer displayes a radiobutton with the selected status corresponding to the actual cell data
set the celltype argument as Column.RADIOBUTTON_CELL
set the cellValueToDisplayHash to hashtable which contains a mapping of actual cell data to the
checkbox selection state
For example, lets say the database contains "A" for employee alive, "D" for employee dead
and if you want to set the radiobutton selected when "A" and unselected when "D"
Hashtable radioHash = new Hashtable();
radioHash.put("A",new Boolean(true));
radioHash.put("D",new Boolean(false));
yourQuickTable.getColumn(1).setCellRenderer( new DBTableCellRenderer(Column.RADIOBUTTON_CELL, radioHash, yourQuickTable));
comboBox renderer
combox renderer is a label which displayes the combo box editor's selected value
For example, lets say the database contains "A" for employee alive, "D" for employee dead
and if you want to show "Alive" instead of "A" in the combo box list and "Dead" instead of "D"
Hashtable comboHash = new Hashtable();
comboHash.put("A","Alive");
comboHash.put("D","Dead");
yourQuickTable.getColumn(1).setCellRenderer( new DBTableCellRenderer(Column.COMBOBOX_CELL, comboHash, yourQuickTable));
Date reneder
Date renderer displays a label which shows the date in the given date format
You have to pass the string date format in which you want the date to be displayed
Example
Hashtable datePatternHash = new Hashtable();
datePatternHash.put("pattern","DD-MM-YYYY");
yourQuickTable.getColumn(1).setCellRenderer( new DBTableCellEditor(Column.DATE_CELL, datePatternHash, yourQuickTable));
cellType - Any one of Column.IMAGE_CELL or Column.CHECKBOX_CELL or Column.RADIOBUTTON_CELL or Column.COMBOBOX_CELLcellValueToDisplayHash - hashtable which contains a mapping of actual cell data to the display datadBTable - quicktable in which this cell renderer is usedDBTable.setCellComponent(Column, int, Hashtable)
public DBTableCellRenderer(CellComponent cc,
DBTable dBTable)
Column.setUserCellRenderer(CellComponent)| Method Detail |
public void updateUI()
JComponent.updateUI()
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
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||