javax.swing.CellEditor Java Examples

The following examples show how to use javax.swing.CellEditor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PropertySheetTable.java    From CodenameOne with GNU General Public License v2.0 6 votes vote down vote up
public void actionPerformed(ActionEvent e) {
  JTable table = (JTable)e.getSource();
  if (!table.hasFocus()) {
    CellEditor cellEditor = table.getCellEditor();
    if (cellEditor != null && !cellEditor.stopCellEditing()) { return; }
    table.requestFocus();
    return;
  }
  ListSelectionModel rsm = table.getSelectionModel();
  int anchorRow = rsm.getAnchorSelectionIndex();
  table.editCellAt(anchorRow, PropertySheetTableModel.VALUE_COLUMN);
  Component editorComp = table.getEditorComponent();
  if (editorComp != null) {
    editorComp.requestFocus();
  }
}
 
Example #2
Source File: TableEditorTable.java    From ramus with GNU General Public License v3.0 5 votes vote down vote up
public TableEditorTable(List<Attribute> attributes, GUIFramework framework) {
    this.framework = framework;
    this.attributes = attributes;
    plugins = new AttributePlugin[attributes.size()];
    cellEditors = new TableCellEditor[plugins.length];
    cellRenderers = new TableCellRenderer[plugins.length];
    setHorizontalScrollEnabled(true);
    setShowVerticalLines(true);

    getInputMap(JInternalFrame.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(
            KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0),
            "RamusENTER_Action");
    getInputMap(JInternalFrame.WHEN_FOCUSED).put(
            KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0),
            "RamusENTER_Action");
    AbstractAction ramusEnterAction = new AbstractAction() {

        /**
         *
         */
        private static final long serialVersionUID = 4745861738845278043L;

        public void actionPerformed(ActionEvent ae) {
            CellEditor editor = getCellEditor();
            if (editor != null)
                editor.stopCellEditing();
        }
    };

    getActionMap().put("RamusENTER_Action", ramusEnterAction);
}