下面列出了javax.swing.table.TableCellEditor#cancelCellEditing ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public void tableChanged(TableModelEvent e) {
// in case the table changes for the following reasons:
// * the editing row has changed
// * the editing row was removed
// * all rows were changed
// * rows were added
//
// it is better to cancel the editing of the row as our editor
// may no longer be the right one. It happens when you play with
// the sorting while having the focus in one editor.
if (e.getType() == TableModelEvent.UPDATE) {
int first = e.getFirstRow();
int last = e.getLastRow();
int editingRow = PropertySheetTable.this.getEditingRow();
TableCellEditor editor = PropertySheetTable.this.getCellEditor();
if (editor != null && first <= editingRow && editingRow <= last) {
editor.cancelCellEditing();
}
}
}
protected void removeRowActionPerformed(ActionEvent e) {
int row = table.getSelectedRow();
final int column = table.getSelectedColumn();
final TableCellEditor cellEditor = table.getCellEditor(row, column);
if (cellEditor != null) {
cellEditor.cancelCellEditing();
}
InnerTableModel model = (InnerTableModel) table.getModel();
int rowCount = model.getRowCount() - 1;
model.removeRow(row);
model.modelUpdatedFromUI();
if (row >= rowCount) {
row = rowCount - 1;
}
if (row >= 0) {
final int n = row;
Utils.runInAwtDispatchThread(new Runnable() {
public void run() {
selectCell(n, column);
}
});
}
}
private void btnRemoveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRemoveActionPerformed
TableCellEditor editor = table.getCellEditor();
if( null != editor )
editor.cancelCellEditing();
boolean wasValid = isDataValid();
int selRow = table.getSelectedRow();
if( selRow < 0 )
return;
DefaultTableModel model = (DefaultTableModel)table.getModel();
model.removeRow( selRow );
if( selRow > model.getRowCount()-1 )
selRow--;
if( selRow >= 0 )
table.getSelectionModel().setSelectionInterval( selRow, selRow );
boolean wasChanged = changed;
fireChanged();
firePropertyChange( OptionsPanelController.PROP_CHANGED, new Boolean(wasChanged), Boolean.TRUE);
firePropertyChange( OptionsPanelController.PROP_VALID, new Boolean(wasValid), new Boolean(isDataValid()));
}
public void tableChanged(TableModelEvent e) {
// in case the table changes for the following reasons:
// * the editing row has changed
// * the editing row was removed
// * all rows were changed
// * rows were added
//
// it is better to cancel the editing of the row as our editor
// may no longer be the right one. It happens when you play with
// the sorting while having the focus in one editor.
if (e.getType() == TableModelEvent.UPDATE) {
int first = e.getFirstRow();
int last = e.getLastRow();
int editingRow = PropertySheetTable.this.getEditingRow();
TableCellEditor editor = PropertySheetTable.this.getCellEditor();
if (editor != null && first <= editingRow && editingRow <= last) {
editor.cancelCellEditing();
}
}
}
public void cancelCellEditing() {
if (LOGGER.isLoggable(Level.FINER)) {
LOGGER.finer("Cancel Editing Row: "+getEditingRow());
}
final TableCellEditor tableCellEditor = getCellEditor();
if (tableCellEditor != null) {
tableCellEditor.cancelCellEditing();
}
}
void update() {
JTable table = provider.getTable();
TableCellEditor cellEditor = table.getCellEditor();
if (cellEditor != null) {
cellEditor.cancelCellEditing();
}
populateMap();
}
@Override
public void tableRowsChanged() {
TableCellEditor cellEditor = varnodeTable.getCellEditor();
if (cellEditor != null) {
if (!cellEditor.stopCellEditing()) {
cellEditor.cancelCellEditing();
}
}
}
public void cancelCellEditing() {
if (LOGGER.isLoggable(Level.FINER)) {
LOGGER.finer("Cancel Editing Row: "+getEditingRow());
}
final TableCellEditor tableCellEditor = getCellEditor();
if (tableCellEditor != null) {
tableCellEditor.cancelCellEditing();
}
}
public void cancelCellEditing() {
if (LOGGER.isLoggable(Level.FINER)) {
LOGGER.finer("Cancel Editing Row: "+getEditingRow());
}
final TableCellEditor tableCellEditor = getCellEditor();
if (tableCellEditor != null) {
tableCellEditor.cancelCellEditing();
}
}
public void cancelCellEditing() {
if (LOGGER.isLoggable(Level.FINER)) {
LOGGER.finer("Cancel Editing Row: "+getEditingRow());
}
final TableCellEditor tableCellEditor = getCellEditor();
if (tableCellEditor != null) {
tableCellEditor.cancelCellEditing();
}
}
@Override
public void attrValueChanged(AttrTableModelEvent e) {
if (e.getSource() != attrModel) {
attrModel.removeAttrTableModelListener(this);
return;
}
int row = e.getRowIndex();
TableCellEditor ed = table.getCellEditor();
if (row >= 0 && ed instanceof CellEditor && attrModel.getRow(row) == ((CellEditor) ed).currentRow) {
ed.cancelCellEditing();
}
fireTableChanged();
}
/**
* Cancels on-going cell editing
*/
public void cancelEditing() {
TableCellEditor editor = getCellEditor();
if (editor != null) {
editor.cancelCellEditing();
}
}
public void cancelCellEditing() {
if (LOGGER.isLoggable(Level.FINER)) {
LOGGER.finer("Cancel Editing Row: "+getEditingRow());
}
final TableCellEditor tableCellEditor = getCellEditor();
if (tableCellEditor != null) {
tableCellEditor.cancelCellEditing();
}
}
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();
}
public void cancelCellEditing() {
if (LOGGER.isLoggable(Level.FINER)) {
LOGGER.finer("Cancel Editing Row: "+getEditingRow());
}
final TableCellEditor tableCellEditor = getCellEditor();
if (tableCellEditor != null) {
tableCellEditor.cancelCellEditing();
}
}
public void cancelCellEditing() {
if (LOGGER.isLoggable(Level.FINER)) {
LOGGER.finer("Cancel Editing Row: "+getEditingRow());
}
final TableCellEditor tableCellEditor = getCellEditor();
if (tableCellEditor != null) {
tableCellEditor.cancelCellEditing();
}
}
/**
* Cancels on-going cell editing
*/
public void cancelEditing() {
TableCellEditor editor = getCellEditor();
if (editor != null) {
editor.cancelCellEditing();
}
}
public void cancelCellEditing() {
if (LOGGER.isLoggable(Level.TRACE)) {
LOGGER.log(Level.TRACE, "Cancel Editing Row: "+getEditingRow());
}
final TableCellEditor tableCellEditor = getCellEditor();
if (tableCellEditor != null) {
tableCellEditor.cancelCellEditing();
}
}
public void cancelCellEditing() {
if (LOGGER.isLoggable(Level.FINER)) {
LOGGER.finer("Cancel Editing Row: "+getEditingRow());
}
final TableCellEditor tableCellEditor = getCellEditor();
if (tableCellEditor != null) {
tableCellEditor.cancelCellEditing();
}
}
@Override
public void attrStructureChanged(AttrTableModelEvent e) {
if (e.getSource() != attrModel) {
attrModel.removeAttrTableModelListener(this);
return;
}
TableCellEditor ed = table.getCellEditor();
if (ed != null) {
ed.cancelCellEditing();
}
fireTableChanged();
}