本文整理汇总了Java中javax.swing.table.TableCellEditor.addCellEditorListener方法的典型用法代码示例。如果您正苦于以下问题:Java TableCellEditor.addCellEditorListener方法的具体用法?Java TableCellEditor.addCellEditorListener怎么用?Java TableCellEditor.addCellEditorListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.table.TableCellEditor
的用法示例。
在下文中一共展示了TableCellEditor.addCellEditorListener方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: editCellAt
import javax.swing.table.TableCellEditor; //导入方法依赖的package包/类
public boolean editCellAt(int index, EventObject e) {
if (cellEditor != null && !cellEditor.stopCellEditing()) {
return false;
}
if (!isCellEditable(index)) {
return false;
}
TableCellEditor editor = getCellEditor(index);
if (editor != null && editor.isCellEditable(e)) {
editorComp = prepareEditor(editor, index);
editorComp.setBounds(getHeaderRect(index));
add(editorComp);
editorComp.validate();
setCellEditor(editor);
setEditingColumn(index);
editor.addCellEditorListener(this);
return true;
}
return false;
}
示例2: editCellAt
import javax.swing.table.TableCellEditor; //导入方法依赖的package包/类
/**
* Programmatically starts editing the cell at <code>row</code> and <code>column</code>, if
* those indices are in the valid range, and the cell at those indices is editable. To prevent
* the <code>JTable</code> from editing a particular table, column or cell value, return false
* from the <code>isCellEditable</code> method in the <code>TableModel</code> interface.
*
* @param row
* the row to be edited
* @param column
* the column to be edited
* @param e
* event to pass into <code>shouldSelectCell</code>; note that as of Java 2 platform
* v1.2, the call to <code>shouldSelectCell</code> is no longer made
* @return false if for any reason the cell cannot be edited, or if the indices are invalid
*/
@Override
public boolean editCellAt(int row, int column, 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;
}
TableCellEditor editor = getCellEditor(row, column);
if (editor != null && editor.isCellEditable(e)) {
editorComp = prepareEditor(editor, row, column);
if (editorComp == null) {
removeEditor();
return false;
}
editorComp.setBounds(getCellRect(row, column, false));
add(editorComp);
editorComp.validate();
editorComp.repaint();
setCellEditor(editor);
setEditingRow(row);
setEditingColumn(column);
editor.addCellEditorListener(this);
return true;
}
return false;
}