|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object quick.dbtable.CellPropertiesModel
CellPropertiesModel can be used to set the properties of each cell in the table.
The properties which can be set are 1) Font 2) Background color 3) Foreground Color 4) Alignment Extend this class to create your own model For example if you want to set the Font of first row to Arial, implement the getFont() as below public Font getFont(int row, int col) { if( row == 0) return new Font(..); //don't create the font everytime, create once in constructor & reuse it else return null; //returning null will give the default color } if you want to set the background colors of columns alternatively to two colors the public Color getBackground(int row, int col) { if( col %2 == 0) return Color.blue; else return null; } if you want to set the Foreground colors of all the employees whose salary is greater than 10000 public Color getForeground(int row, int col) { int sal = Integer.intValue((Integer)yourQuickTable.getTable().getValueAt(row, 1)); if( sal > 10000) return Color.red; else return Color.black; } Source code of CellPropertiesModel public class CellPropertiesModel implements Serializable { public Font getFont(int row, int col) { return null; } public Color getForeground(int row, int col) { return null; } public Color getBackground(int row, int col) { return null; } public int getAlignment(int row, int col) { return -1; } public int getCellEditable(int row, int col) { return -1; } } Example of creating a Cellproperties model CellPropertiesModel simpleCellModel = new CellPropertiesModel() { Color darkGreen = new Color(45,45,45); public Color getForeground(int row, int col) { return darkGreen; } public int getAlignment(int row, int col) { if( col== 0 ) return SwingConstants.LEFT; else return SwingConstants.RIGHT; } }; yourQuicktable.setCellPropertiesModel(simpleCellModel);
DBTable.setCellPropertiesModel(CellPropertiesModel)
,
Serialized FormConstructor Summary | |
CellPropertiesModel()
|
Method Summary | |
int |
getAlignment(int row,
int col)
return the alignment for this row & column if you don't want to set any alignmnet or if you want to set the default alignmnet for particular row, col, return -1 use SwingConstants.LEFT, SwingConstants.CENTER, SwingConstants.RIGHT for alignment |
java.awt.Color |
getBackground(int row,
int col)
return the background color for this row & column if you don't want to set any color or if you want to set the default color for particular row, col, return null |
int |
getCellEditable(int row,
int col)
By default, whether a cell is editable or not is decided by column.getReadOnly() or by dbTable.setEditable() method But if you need to control the editable property of each cell, you can use this method. |
java.awt.Font |
getFont(int row,
int col)
return the font for this row & column if you don't want to set any font and if you want to set a default font for particular row, col, return null |
java.awt.Color |
getForeground(int row,
int col)
return the foreground color for this row & column if you don't want to set any color or if you want to set the default color for particular row, col, return null |
java.awt.Color |
getSelectionBackground(int row,
int col)
return the background color for this row & column, when it is selected if you don't want to set any color or if you want to set the default color for particular row, col, return null |
java.awt.Color |
getSelectionForeground(int row,
int col)
return the foreground color for this row & column, when it is selected if you don't want to set any color or if you want to set the default color for particular row, col, return null |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public CellPropertiesModel()
Method Detail |
public java.awt.Font getFont(int row, int col)
public java.awt.Color getForeground(int row, int col)
public java.awt.Color getBackground(int row, int col)
public java.awt.Color getSelectionForeground(int row, int col)
public java.awt.Color getSelectionBackground(int row, int col)
public int getAlignment(int row, int col)
public int getCellEditable(int row, int col)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |