use of javax.swing.event.CellEditorListener in project cytoscape-api by cytoscape.
the class AbstractCellEditorTest method testAddCellEditorListener.
@Test
public void testAddCellEditorListener() {
CellEditorListener l = mock(CellEditorListener.class);
editor.addCellEditorListener(l);
assertEquals(1, editor.listenerList.getListenerCount());
editor.removeCellEditorListener(l);
assertEquals(0, editor.listenerList.getListenerCount());
}
use of javax.swing.event.CellEditorListener in project intellij-community by JetBrains.
the class DynamicMethodDialog method setupParameterTable.
private void setupParameterTable(final List<ParamInfo> pairs) {
MySuggestedNameCellEditor suggestedNameCellEditor = new MySuggestedNameCellEditor(QuickfixUtil.getArgumentsNames(pairs));
myParametersTable.setDefaultEditor(String.class, suggestedNameCellEditor);
suggestedNameCellEditor.addCellEditorListener(new CellEditorListener() {
@Override
public void editingStopped(ChangeEvent e) {
final int editingColumn = myParametersTable.getSelectedColumn();
if (editingColumn != 0)
return;
final int editingRow = myParametersTable.getSelectedRow();
if (editingRow < 0 || editingRow >= pairs.size())
return;
String newNameValue = ((MySuggestedNameCellEditor) e.getSource()).getCellEditorValue();
final ParamInfo editingPair = pairs.get(editingRow);
editingPair.name = newNameValue;
}
@Override
public void editingCanceled(ChangeEvent e) {
}
});
}
use of javax.swing.event.CellEditorListener in project jdk8u_jdk by JetBrains.
the class XTextFieldEditor method fireEditingStopped.
protected void fireEditingStopped() {
CellEditorListener listener;
Object[] listeners = evtListenerList.getListenerList();
for (int i = 0; i < listeners.length; i++) {
if (listeners[i] == CellEditorListener.class) {
listener = (CellEditorListener) listeners[i + 1];
listener.editingStopped(changeEvent);
}
}
}
use of javax.swing.event.CellEditorListener in project jdk8u_jdk by JetBrains.
the class bug6711682 method createAndShowGUI.
private static void createAndShowGUI() {
editorCb = new JCheckBox();
rendererCb = new JCheckBox();
JFrame f = new JFrame("Table with CheckBox");
Container p = f.getContentPane();
p.setLayout(new BorderLayout());
table = new JTable(new Object[][] { { false }, { false }, { false } }, new Object[] { "CheckBox" });
TableCellEditor editor = new TableCellEditor() {
int editedRow;
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
this.editedRow = row;
editorCb.setSelected(Boolean.TRUE.equals(value));
editorCb.setBackground(UIManager.getColor("Table.selectionBackground"));
return editorCb;
}
public void addCellEditorListener(CellEditorListener l) {
}
public void cancelCellEditing() {
}
public Object getCellEditorValue() {
return editorCb.isSelected();
}
public boolean isCellEditable(EventObject anEvent) {
return true;
}
public void removeCellEditorListener(CellEditorListener l) {
}
public boolean shouldSelectCell(EventObject anEvent) {
return true;
}
public boolean stopCellEditing() {
table.getModel().setValueAt(editorCb.isSelected(), editedRow, 0);
return true;
}
};
table.getColumnModel().getColumn(0).setCellEditor(editor);
TableCellRenderer renderer = new TableCellRenderer() {
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
rendererCb.setSelected(Boolean.TRUE.equals(value));
return rendererCb;
}
};
table.getColumnModel().getColumn(0).setCellRenderer(renderer);
p.add(table, BorderLayout.CENTER);
f.pack();
f.setVisible(true);
}
use of javax.swing.event.CellEditorListener in project JMRI by JMRI.
the class ValueEditor method fireEditingStopped.
protected void fireEditingStopped() {
if (log.isDebugEnabled()) {
log.debug("fireEditingStopped");
}
Vector<CellEditorListener> local;
synchronized (listeners) {
local = new Vector<CellEditorListener>(listeners);
}
ChangeEvent ce = new ChangeEvent(this);
for (int i = local.size() - 1; i >= 0; i--) {
local.elementAt(i).editingStopped(ce);
}
}
Aggregations