Java Code Examples for javax.swing.JTable#isEditing()

The following examples show how to use javax.swing.JTable#isEditing() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RTable.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
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;
    }
}
 
Example 2
Source File: BaseTable.java    From netbeans with Apache License 2.0 6 votes vote down vote up
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);
        }
    }
}
 
Example 3
Source File: JTableJavaElement.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 4
Source File: GuiUtil.java    From jts with GNU Lesser General Public License v2.1 5 votes vote down vote up
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();
    }
}