Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.awt.Component;

import javax.swing.AbstractCellEditor;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.table.TableCellEditor;
import javax.swing.table.TableColumn;

public class Main {
    public static void main(String[] argv) throws Exception {
        JTable table = new JTable();
        TableColumn col = table.getColumnModel().getColumn(0);
        col.setCellEditor(new MyTableCellEditor());
    }
}

class MyTableCellEditor extends AbstractCellEditor implements TableCellEditor {
    public boolean stopCellEditing() {
        String s = (String) getCellEditorValue();

        return super.stopCellEditing();
    }

    JTextField field = new JTextField();

    public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row,
            int column) {

        return field;
    }

    public Object getCellEditorValue() {
        return null;
    }
}