Tuesday, April 30, 2013

Wednesday, April 17, 2013

Swing: modify table cell on tab


Override this method in JTable (Source: https://forums.oracle.com/forums/thread.jspa?threadID=1353305)


@Override
    public void changeSelection(
            int row, int column, boolean toggle, boolean extend) {      
        super.changeSelection(row, column, toggle, extend);
        //  Place cell in edit mode when it 'gains focus'

        if (editCellAt(row, column)) {
            Component editor = getEditorComponent();
            editor.requestFocusInWindow();
            ((JFormattedTextField)editor).selectAll();
        }
    }


Ref
http://stackoverflow.com/questions/14206083/jtable-edit-on-keypress
http://stackoverflow.com/questions/9091208/jtable-enter-key/9095442#9095442
http://www.java2s.com/Tutorial/Java/0260__Swing-Event/MaketheENTERkeyactliketheTABkey.htm
http://www.java2s.com/Tutorial/Java/0260__Swing-Event/SettingFocusTraversalKeysinaComponent.htm
http://www.java2s.com/Tutorial/Java/0260__Swing-Event/KeyListenerandKeyEvent.htm