C
- the editor component classpublic abstract class AbstractGenericEditor<C extends JComponent> extends Object implements GenericEditor
public class MyGenericEditor extends AbstractGenericEditor<MyGenericPanel> { public MyGenericEditor(JTable table) { super(table); editor = new TestGenericPanel(); } public Object getValue() { return editor.getValue(); } public void setValue(Object value) { editor.setValue((Boolean) value); } public class MyGenericPanel extends JPanel { private final JCheckBox cb = new JCheckBox("CheckBox"); private TestGenericPanel() { this.setLayout(new BorderLayout()); this.add(cb, BorderLayout.CENTER); } public boolean getValue() { return cb.isSelected(); } public int getClickCountToStart() { return 2; } public void setValue(boolean b) { cb.setSelected(b); } }And we would set table as:
DefaultTableModel model = new DefaultTableModel(); model.addColumn("Value"); Vector<Object> v = new Vector<>(); v.add(true); model.addRow(v); v = new Vector<>(); v.add(1); model.addRow(v); ExtendedEditorTable table = new ExtendedEditorTable(model); TestGenericEditor editor = new TestGenericEditor(table); table.addEditor(0, 0, new ExtendedCellEditor(editor)); table.addOpenEditorListener(0, 0, editor.getAppproveListener());
Modifier and Type | Class and Description |
---|---|
static class |
AbstractGenericEditor.ApproveListener
The default listener which will be fired when approving the editor changes.
|
Modifier and Type | Field and Description |
---|---|
protected AbstractAction |
cancelaction
The Cancel action.
|
protected JComponent |
cellComp
The component to use in the table for the TableCell.
|
protected C |
editor
The editor component.
|
protected JDialog |
editorDialog
The Dialog window used by the Editor.
|
protected JFrame |
frame
The parent frame.
|
protected JComponent |
parent
The parent component.
|
protected int |
returnValue
The return value;
|
protected AbstractAction |
yesaction
The Yes action.
|
protected JPanel |
yesnopanel
The Yes / Cancel Panel.
|
Constructor and Description |
---|
AbstractGenericEditor(JComponent parent)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addActionListener(ActionListener listener)
Do nothing by default.
|
protected JPanel |
createYesNoPanel()
Create the Yes / No bottom Panel.
|
protected void |
doCancel()
Called when user click on Cancel button.
|
protected void |
doYes()
Called when user click on Yes button.
|
ActionListener |
getAppproveListener()
Return the listener which will be fired when approving the editor changes.
|
C |
getEditor()
Return the Editor component.
|
JComponent |
getEditorComponent()
Return the component to use for the
PropertyEditor s or JTable. |
JComponent |
getParent()
Return the parent component.
|
JFrame |
getParentFrame()
Return the parent frame.
|
String |
getTitle()
Return the dialog title.
|
void |
performApproveAction()
Called when the editor is closed after
JFileChooser.APPROVE_OPTION . |
void |
setAppproveListener(ActionListener listener)
Set the listener which will be fired when approving the editor changes.
|
void |
setEditor(C editor)
Set the Editor component.
|
void |
setTitle(String title)
Set the dialog title.
|
protected void |
setUp()
Set up the panel contents.
|
int |
showDialog()
Open the dialog, and return the result of the opening.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getClickCountToStart, getValue, setValue
protected JComponent cellComp
protected JDialog editorDialog
protected JPanel yesnopanel
protected AbstractAction yesaction
protected AbstractAction cancelaction
protected int returnValue
protected JFrame frame
protected JComponent parent
protected C extends JComponent editor
public AbstractGenericEditor(JComponent parent)
parent
- the parentpublic void setAppproveListener(ActionListener listener)
listener
- the listener.public ActionListener getAppproveListener()
public void setEditor(C editor)
editor
- the componentpublic C getEditor()
public JFrame getParentFrame()
public JComponent getParent()
public void setTitle(String title)
title
- the titlepublic String getTitle()
public void addActionListener(ActionListener listener)
addActionListener
in interface GenericEditor
listener
- the listenerprotected JPanel createYesNoPanel()
protected void setUp()
protected void doYes()
protected void doCancel()
public int showDialog() throws HeadlessException
JFileChooser.showOpenDialog(java.awt.Component)
HeadlessException
public void performApproveAction()
JFileChooser.APPROVE_OPTION
. Do nothing by default.public JComponent getEditorComponent()
PropertyEditor
s or JTable. By default it will be a JTextField.getEditorComponent
in interface GenericEditor