Exemplo n.º 1
0
  public boolean editCellAt(final int row, final int column, final EventObject e) {
    if (cellEditor != null && !cellEditor.stopCellEditing()) {
      return false;
    }

    if (row < 0 || row >= getRowCount() || column < 0 || column >= getColumnCount()) {
      return false;
    }

    if (!isCellEditable(row, column)) {
      return false;
    }

    if (myEditorRemover == null) {
      final KeyboardFocusManager keyboardFocusManager =
          KeyboardFocusManager.getCurrentKeyboardFocusManager();
      myEditorRemover = new MyCellEditorRemover();
      //noinspection HardCodedStringLiteral
      keyboardFocusManager.addPropertyChangeListener("focusOwner", myEditorRemover);
      //noinspection HardCodedStringLiteral
      keyboardFocusManager.addPropertyChangeListener("permanentFocusOwner", myEditorRemover);
    }

    final TableCellEditor editor = getCellEditor(row, column);
    if (editor != null && editor.isCellEditable(e)) {
      editorComp = prepareEditor(editor, row, column);
      // ((JComponent)editorComp).setBorder(null);
      if (editorComp == null) {
        removeEditor();
        return false;
      }
      editorComp.setBounds(getCellRect(row, column, false));
      add(editorComp);
      editorComp.validate();

      IdeFocusManager.findInstanceByComponent(this).requestFocus(editorComp, false);

      setCellEditor(editor);
      setEditingRow(row);
      setEditingColumn(column);
      editor.addCellEditorListener(this);
      if (isTypeAhead) {
        JTableCellEditorHelper.typeAhead(this, e, row, column);
      }
      return true;
    }
    return false;
  }
 public void stopEditing() {
   TableCellEditor editor = myTable.getCellEditor();
   if (editor != null) {
     editor.stopCellEditing();
   }
 }
Exemplo n.º 3
0
 public void stopCellEditing() {
   TableCellEditor editor;
   if ((editor = getCellEditor()) != null) editor.stopCellEditing();
 }