下面列出了javax.swing.JTable#isEditing ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public RTable(Component source, JSONOMapConfig omapConfig, Point point, IJSONRecorder recorder) {
super(source, omapConfig, point, recorder);
JTable table = (JTable) source;
if (table.isEditing()) {
column = table.getEditingColumn();
row = table.getEditingRow();
} else {
if (point != null) {
row = table.rowAtPoint(point);
column = table.columnAtPoint(point);
} else {
row = table.getSelectedRow();
column = table.getSelectedColumn();
}
}
if (row == -1 || column == -1) {
row = column = -1;
}
}
public void actionPerformed(ActionEvent ae) {
JTable jt = (JTable) ae.getSource();
if (jt != null) {
if (jt.isEditing()) {
TableCellEditor tce = jt.getCellEditor();
if (PropUtils.isLoggable(BaseTable.class)) {
PropUtils.log(BaseTable.class, "Cancelling edit due to keyboard event"); //NOI18N
}
if (tce != null) {
jt.getCellEditor().cancelCellEditing();
}
} else {
//If we're in a dialog, try to close it
trySendEscToDialog(jt);
}
}
}
@Override
public boolean marathon_select(String text) {
JTable table = (JTable) component;
boolean cellEditing = table.isEditing();
if (cellEditing) {
return true;
}
if ("".equals(text)) {
table.clearSelection();
return true;
}
int[] rows;
int[] cols;
if ("all".equals(text)) {
int rowCount = table.getRowCount();
int columnCount = table.getColumnCount();
rows = new int[rowCount];
cols = new int[columnCount];
for (int i = 0; i < rowCount; i++) {
rows[i] = i;
}
for (int i = 0; i < columnCount; i++) {
cols[i] = i;
}
} else {
rows = parseRows(text);
String[] colNames = parseCols(text);
cols = new int[colNames.length];
for (int i = 0; i < colNames.length; i++) {
cols[i] = getColumnIndex(colNames[i]);
}
}
return selectRowsColumns(table, rows, cols);
}
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();
}
}