|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
CellComponent is used to create user defined editor renderer for quicktable.
Example
class MyCell implements CellComponent
{
JCombobox myCombo = new JCombobox();
MyCell()
{
myCombo.addItem("Alive");
myCombo.addItem("Dead");
myCombo.addItem("Leave");
}
public void setValue(Object value)
{
myCombo.setSelectedItem(value);
//handle the case if null is passed
}
public Object getValue()
{
return myCombo.getSelectedItem();
//return "" if nothing is selected
}
public JComponent getComponent()
{
return mycombo;
}
public void addActionListener(ActionListener listener)
{
mycombo.addActionListener(listener)
}
}
yourQuickTable.getColumn(1).setUserCellEditor(new MyCell());
Column.setUserCellEditor(CellComponent),
Column.setUserCellRenderer(CellComponent)| Method Summary | |
void |
addActionListener(java.awt.event.ActionListener listener)
If this cell component is a cell editor & if it wants to notify the table that editing is completed, the actionlistener in this method should be notified. |
javax.swing.JComponent |
getComponent()
returns the JComponent which is used as the component |
java.lang.Object |
getValue()
returns the data from the editor/renederer |
void |
setValue(java.lang.Object val)
sets the data to the renderer/editor |
| Method Detail |
public void setValue(java.lang.Object val)
public java.lang.Object getValue()
public javax.swing.JComponent getComponent()
public void addActionListener(java.awt.event.ActionListener listener)
e.g. If the cell component is a combo box
public void addActionListener(ActionListener listener)
{
yourComboBox.addActionListener(listener)
}
So the combo box will notify JTable, whenever the data is changed.
If the JComponent which you are using in your cellcomponent doesn't have a
addActionListener method, or if the cell component only fires some other
type event like itemChanged, then all you have to do is, notify the listener
whenever there is a change in data using listener.actionPerformed(null);
e.g
class MyCellCompoenent implements CellComponent
{
ActionListener listener;
...
public void addActionListener(ActionListener listener)
{
this.listener = listener;
}
public void valueChangedInMyJComponent()
{
listener.actionPerformed( null );
}
}
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||