javax.swing.table.TableCellEditor类的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(8.3k)|赞(0)|评价(0)|浏览(96)

本文整理了Java中javax.swing.table.TableCellEditor类的一些代码示例,展示了TableCellEditor类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TableCellEditor类的具体详情如下:
包路径:javax.swing.table.TableCellEditor
类名称:TableCellEditor

TableCellEditor介绍

暂无

代码示例

代码示例来源:origin: winder/Universal-G-Code-Sender

@Override
public void save() {
  TableCellEditor editor = customRemoverTable.getCellEditor();
  if (editor != null) {
    editor.stopCellEditing();
  DefaultTableModel model = (DefaultTableModel) this.customRemoverTable.getModel();
  for (int i = 0; i < customRemoverTable.getRowCount(); i++) {
    JsonObject args = new JsonObject();
    String pattern = model.getValueAt(i, 1).toString();

代码示例来源:origin: pentaho/mondrian

/**
 * Several methods are called, e.g. editCellAt,  to get the focus set in the
 * value column of the specified row.  The attribute column has the
 * parameter name and should not receive focus.
 */
protected void setTableCellFocus(int row) {
  propertyTable.editCellAt(row, 1);
  TableCellEditor editor = propertyTable.getCellEditor(row, 1);
  Component comp = editor.getTableCellEditorComponent(
    propertyTable, propertyTable.getValueAt(row, 1), true, row, 1);
}

代码示例来源:origin: undera/jmeter-plugins

private JTable createGrid() {
  grid = new JTable();
  grid.getDefaultEditor(String.class).addCellEditorListener(this);
  createTableModel();
  grid.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  grid.setMinimumSize(new Dimension(200, 100));
  return grid;
}

代码示例来源:origin: cmu-phil/tetrad

public void actionPerformed(ActionEvent e) {
    int nodeIndex = getEditingTableModel().getNodeIndex();
    BayesIm bayesIm = getBayesIm();
    if (!existsIncompleteRow(bayesIm, nodeIndex)) {
      JOptionPane.showMessageDialog(JOptionUtils.centeringComp(),
          "There are no incomplete rows in this table.");
      return;
    }
    BayesEstimatorNodeEditingTable editingTable =
        BayesEstimatorNodeEditingTable.this;
    TableCellEditor cellEditor = editingTable.getCellEditor();
    if (cellEditor != null) {
      cellEditor.cancelCellEditing();
    }
    bayesIm.randomizeIncompleteRows(nodeIndex);
    getEditingTableModel().fireTableDataChanged();
    firePropertyChange("modelChanged", null, null);
  }
});

代码示例来源:origin: omegat-org/omegat

@Override
  public void persist() {
    TableCellEditor editor = panel.entryTable.getCellEditor();
    if (editor != null) {
      editor.stopCellEditing();
    }

    Autotext.setList(((AutotextTableModel) panel.entryTable.getModel()).getData());

    try {
      Autotext.save();
    } catch (IOException ex) {
      JOptionPane.showMessageDialog(panel, OStrings.getString("AC_AUTOTEXT_UNABLE_TO_SAVE"));
    }

    Preferences.setPreference(Preferences.AC_AUTOTEXT_SORT_BY_LENGTH, panel.sortByLengthCheckBox.isSelected());
    Preferences.setPreference(Preferences.AC_AUTOTEXT_SORT_ALPHABETICALLY,
        panel.sortAlphabeticallyCheckBox.isSelected());
    Preferences.setPreference(Preferences.AC_AUTOTEXT_SORT_FULL_TEXT, panel.sortFullTextCheckBox.isSelected());
    Preferences.setPreference(Preferences.AC_AUTOTEXT_ENABLED, panel.enabledCheckBox.isSelected());
  }
}

代码示例来源:origin: cmu-phil/tetrad

public void actionPerformed(ActionEvent e) {
    int nodeIndex = getEditingTableModel().getNodeIndex();
    DirichletBayesIm dirichletBayesIm = getDirichletBayesIm();
    if (existsCompleteRow(dirichletBayesIm, nodeIndex)) {
      int ret = JOptionPane.showConfirmDialog(
          JOptionUtils.centeringComp(),
          "This will delete all values in the table. " +
              "Continue?", "Warning",
          JOptionPane.YES_NO_OPTION);
      if (ret == JOptionPane.NO_OPTION) {
        return;
      }
    }
    DirichletBayesImNodeProbsTable editingTable =
        DirichletBayesImNodeProbsTable.this;
    TableCellEditor cellEditor = editingTable.getCellEditor();
    if (cellEditor != null) {
      cellEditor.cancelCellEditing();
    }
    dirichletBayesIm.clearTable(nodeIndex);
    getEditingTableModel().fireTableDataChanged();
  }
});

代码示例来源:origin: omegat-org/omegat

@Override
  public void actionPerformed(ActionEvent e) {
    boolean doneEditing = Stream.of(dialog.tableMapping, dialog.tableRepositories)
        .map(JTable::getCellEditor).allMatch(editor -> editor == null || editor.stopCellEditing());
    if (!doneEditing) {
      return;
    }
    String r = isValid();
    if (r != null) {
      JOptionPane.showMessageDialog(dialog, r, OStrings.getString("TF_ERROR"),
          JOptionPane.ERROR_MESSAGE);
      return;
    }
    result = getData();
    dialog.dispose();
  }
});

代码示例来源:origin: magefree/mage

@Override
public void mouseReleased(MouseEvent arg0) {
  if (isButtonColumnEditor && table.isEditing()) {
    table.getCellEditor().stopCellEditing();
  }
  isButtonColumnEditor = false;
}

代码示例来源:origin: DSpace/DSpace

/**
 * Show the dialog and return the status code.
 *
 * @return The status code returned from the dialog.
 */
public int show() {
  int result = JOptionPane.showOptionDialog(parentFrame,
                       controls,
                       "Edit Properties",
                       JOptionPane.OK_CANCEL_OPTION,
                       JOptionPane.PLAIN_MESSAGE,
                       null,
                       options,
                       null);
  // cancel any edit in the table. If there is a cell editing, the getEditingColumn will
  // return a non-negative column number. This can be used to retreive the cell editor.
  // The code then gets the default editor and calls the stopCellEditing. If custom
  // editors are used, an additional check must be made to get the cell editor
  // for a specific cell.
  int column = propertiesTable.getEditingColumn();
  if (column > -1) {
    TableCellEditor editor = propertiesTable.getDefaultEditor(propertiesTable.getColumnClass(column));
    if (editor != null) {
      editor.stopCellEditing();
    }
  }
  return result;
}

代码示例来源:origin: org.apache.jmeter/jorphan

/**
 * Stop any editing that is currently being done on the table. This will
 * save any changes that have already been made.
 *
 * @param table the table to stop on editing
 */
public static void stopTableEditing(JTable table) {
  if (table.isEditing()) {
    TableCellEditor cellEditor = table.getCellEditor(table.getEditingRow(), table.getEditingColumn());
    cellEditor.stopCellEditing();
  }
}

代码示例来源:origin: locationtech/jts

public static void commitChanges(JTable table) {
  if (table.isEditing()) {
    String text = ((JTextComponent) table.getEditorComponent()).getText();
    table.setValueAt(text, table.getEditingRow(), table.getEditingColumn());
    table.getCellEditor().cancelCellEditing();
  }
}

代码示例来源:origin: de.dfki.mary/marytts-builder

private void stopTableEditing() {
  if (table.isEditing()) {
    TableCellEditor ed = table.getCellEditor();
    assert ed != null;
    boolean success = ed.stopCellEditing(); // we first try to save
    if (!success) {
      ed.cancelCellEditing();
    }
    assert !table.isEditing();
  }
}

代码示例来源:origin: org.swinglabs.swingx/swingx-all

/**
 * {@inheritDoc}
 * <p>
 * Overridden to try to stop the edit, if appropiate. Calls super if
 * succeeded, does not yield otherwise.
 * 
 */
@Override
public void transferFocusBackward() {
  if (isEditingFocusCycleRoot() && !getCellEditor().stopCellEditing())
    return;
  super.transferFocusBackward();
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-docker-ui

private void randomBindCheckBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_randomBindCheckBoxItemStateChanged
  boolean selected = randomBindCheckBox.isSelected();
  portMappingTable.setEnabled(!selected);
  addExposedButton.setEnabled(!selected);
  addButton.setEnabled(!selected);
  removeButton.setEnabled(!selected);
  TableCellEditor editor = portMappingTable.getCellEditor();
  if (editor != null) {
    editor.cancelCellEditing();
  }
  portMappingTable.clearSelection();
}//GEN-LAST:event_randomBindCheckBoxItemStateChanged

代码示例来源:origin: org.swinglabs.swingx/swingx-core

/**
 * {@inheritDoc}
 * <p>
 * Overridden to try to stop the edit, if appropriate. Calls super if
 * succeeded, does not yield otherwise.
 * 
 */
@Override
public void transferFocus() {
  if (isEditingFocusCycleRoot() && !getCellEditor().stopCellEditing())
    return;
  super.transferFocus();
}

代码示例来源:origin: 4thline/cling

@Override
public ActionArgumentValue[] getInputValues() {
  if (inputArgumentsTable == null) return null;
  // Commit the currently typed value
  if (inputArgumentsTable.getCellEditor() != null)
    inputArgumentsTable.getCellEditor().stopCellEditing();
  return inputArgumentsTable.getArgumentValuesModel().getValues();
}

代码示例来源:origin: io.ultreia.java4all.jaxx/jaxx-runtime

public static void stopEditing(JTable table) {
  TableCellEditor cellEditor = table.getCellEditor();
  if (cellEditor != null) {
    cellEditor.cancelCellEditing();
  }
}

代码示例来源:origin: org.terracotta.modules/tim-ehcache-2.x-ui

private void stopCellEditing() {
 TableCellEditor tce;
 if ((tce = clusteredCacheTable.getCellEditor()) != null && !tce.stopCellEditing()) {
  tce.cancelCellEditing();
 }
 if ((tce = standaloneCacheTable.getCellEditor()) != null && !tce.stopCellEditing()) {
  tce.cancelCellEditing();
 }
}

代码示例来源:origin: org.swinglabs.swingx/swingx-core

@Override
public void actionPerformed(ActionEvent e) {
  if (!isEditing())
    return;
  getCellEditor().cancelCellEditing();
}

代码示例来源:origin: de.sciss/jtreetable

@Override
public Component getTreeTableCellEditorComponent(TreeTable treeTable,
    Object value, boolean sel, int row, int col) {
  return ((TableCellEditor)defaultEditor).getTableCellEditorComponent(
      table, value, sel, row, col);
}

相关文章