How to select all text in JTable cell when editing

后端 未结 3 1612
遇见更好的自我
遇见更好的自我 2021-01-02 02:12

I would like to have the editor in my editable JTables select all text in the cell when starting to edit. I have tried a couple of things that all revolve around calling JT

3条回答
  •  北海茫月
    2021-01-02 02:40

    public class SelectAllCellEditor extends DefaultCellEditor
    {
        public SelectAllCellEditor(final JTextField textField ) {
            super( textField );
            textField.addFocusListener( new FocusAdapter()
            {
                public void focusGained( final FocusEvent e )
                {
                    textField.selectAll();
                }
            } );
        }
    }
    

提交回复
热议问题