Java Utililty Methods JTable Cell Editor

List of utility methods to do JTable Cell Editor

Description

The list of methods to do JTable Cell Editor are organized into topic(s).

Method

voidsetClickCountToStartEditing(JTable table, int count)
set Click Count To Start Editing
for (int columnIndex = 0; columnIndex < table.getColumnCount(); ++columnIndex) {
    TableCellEditor cellEditor = table.getColumnModel().getColumn(columnIndex).getCellEditor();
    if (cellEditor instanceof DefaultCellEditor) {
        ((DefaultCellEditor) cellEditor).setClickCountToStart(count);
voidsetClickCountToStartEditing(JTable table, int count)
set Click Count To Start Editing
((DefaultCellEditor) table.getDefaultEditor(String.class)).setClickCountToStart(count);
voidsetDefaultTableEditorsClicks(JTable table, int clickCountToStart)
setDefaultTableEditorsClicks, This sets the number of clicks required to start the default table editors in the supplied table.
TableCellEditor editor;
editor = table.getDefaultEditor(Object.class);
if (editor instanceof DefaultCellEditor) {
    ((DefaultCellEditor) editor).setClickCountToStart(clickCountToStart);
editor = table.getDefaultEditor(Number.class);
if (editor instanceof DefaultCellEditor) {
    ((DefaultCellEditor) editor).setClickCountToStart(clickCountToStart);
...
voidsetEditable(JSpinner spinner, boolean bool)
Make the spinner text field editable, or not
JSpinner.DefaultEditor editor;
editor = (JSpinner.DefaultEditor) spinner.getEditor();
editor.getTextField().setEditable(bool);
voidsetEditable(JTextComponent component, boolean editable)
set Editable
component.setEditable(editable);
component.setBackground(editable ? NORMAL_BG : NOT_EDITABLE_BG);
voidsetEditable(JTextComponent... components)
set Editable
for (JTextComponent component : components) {
    component.setEditable(true);
voidsetEditableFalse(JTextField field)
Set text field non-editable.
field.setEditable(false);
field.setFocusable(false);
voidsetUneditable(JTextComponent... components)
set Uneditable
for (JTextComponent component : components) {
    component.setEditable(false);
voidsetupComboBoxEditor(TableColumn column, Object[] values)
setup Combo Box Editor
DefaultComboBoxModel model = new DefaultComboBoxModel(values);
JComboBox comboBox = new JComboBox(model);
comboBox.setEditable(false);
column.setCellEditor(new DefaultCellEditor(comboBox));
if (values.length > 1) {
    comboBox.setSelectedIndex(0);
voidstopCellEditing(JTable table)
stop Cell Editing
if (table != null) {
    TableCellEditor editor = table.getCellEditor();
    if (editor != null) {
        if (editor instanceof DefaultCellEditor) {
            ((DefaultCellEditor) editor).stopCellEditing();