public void actionPerformed(ActionEvent e) { JTable table = (JTable) SwingUtilities.getAncestorOfClass(JTable.class, (Component) e.getSource()); int row = table.getEditingRow(); table.getCellEditor().stopCellEditing(); ((DefaultTableModel) table.getModel()).removeRow(row);
@Override public void actionPerformed(ActionEvent e) { if (table.getRowCount() > 0 && table.getRowCount() >= table.getEditingRow() && table.getEditingRow() >= 0) { int row = table.convertRowIndexToModel(table.getEditingRow()); fireEditingStopped(); ActionEvent event = new ActionEvent(table, ActionEvent.ACTION_PERFORMED, TablesUtil.getSearchIdFromTable(table, row)); action.actionPerformed(event); } }
@Override public void run() { row = table.convertRowIndexToModel( table.getEditingRow() ); column = table.convertColumnIndexToModel( table.getEditingColumn() ); oldValue = table.getModel().getValueAt(row, column); newValue = null; }
public void actionPerformed(ActionEvent e) { //FIXME: Java 6 // int row = table.convertRowIndexToModel(table.getEditingRow()); int row = table.getEditingRow(); fireEditingStopped(); for (int i = 0; i < buttons.length; i++) { if (e.getSource().equals(buttons[i])) { final ActionEvent event = new ActionEvent(table, ActionEvent.ACTION_PERFORMED, "" + row); actions[i].actionPerformed(event); break; } } }
@Override public void actionPerformed(ActionEvent e) { int row = table.convertRowIndexToModel(table.getEditingRow()); fireEditingStopped(); // Invoke the Action ActionEvent event = new ActionEvent( table, ActionEvent.ACTION_PERFORMED, "" + row); action.actionPerformed(event); }
public void actionPerformed(ActionEvent e) { int row = table.convertRowIndexToModel(table.getEditingRow()); fireEditingStopped(); // Invoke the Action ActionEvent event = new ActionEvent(table, ActionEvent.ACTION_PERFORMED, "" + row); action.actionPerformed(event); }
@Override public void actionPerformed(ActionEvent e) { int row = table.convertRowIndexToModel(table.getEditingRow()); fireEditingStopped(); // Invoke the Action ActionEvent event = new ActionEvent( table, ActionEvent.ACTION_PERFORMED, Integer.toString(row)); action.actionPerformed(event); }
@Override public void actionPerformed(ActionEvent e) { int row = table.convertRowIndexToModel(table.getEditingRow()); fireEditingStopped(); /* Invoke the Action */ ActionEvent event = new ActionEvent(table, ActionEvent.ACTION_PERFORMED, Integer.toString(row)); action.actionPerformed(event); }
@Override public void actionPerformed(ActionEvent e) { int row = table.convertRowIndexToModel(table.getEditingRow()); fireEditingStopped(); // Invoke the Action ActionEvent event = new ActionEvent(table, ActionEvent.ACTION_PERFORMED, "" + row); //$NON-NLS-1$ action.actionPerformed(event); }
JTable table = new JTable(); table.getEditingColumn(); table.getEditingRow(); table.getEditorComponent();
public void run() { row = table.convertRowIndexToModel(table.getEditingRow()); column = table.convertColumnIndexToModel(table.getEditingColumn()); oldValue = table.getModel().getValueAt(row, column); newValue = null; }
@Override public void run() { this.row = this.table.convertRowIndexToModel(this.table.getEditingRow()); this.column = this.table.convertColumnIndexToModel(this.table.getEditingColumn()); this.oldValue = this.table.getModel().getValueAt(this.row, this.column); this.newValue = null; } }
/** * 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(); } }
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(); } }
/** * cancel any editing that is currently being done on the table. * * @param table the table to cancel on editing * @since 3.1 */ public static void cancelEditing(JTable table) { // If a table cell is being edited, we must cancel the editing if (table != null && table.isEditing()) { TableCellEditor cellEditor = table.getCellEditor(table.getEditingRow(), table.getEditingColumn()); cellEditor.cancelCellEditing(); } }
private void paintCell(final Graphics g, final Rectangle cellRect, final int row, final int column) { if (table.isEditing() && table.getEditingRow() == row && table.getEditingColumn() == column) { Component component = table.getEditorComponent(); component.setBounds(cellRect); component.validate(); } else { TableCellRenderer renderer = table.getCellRenderer(row, column); Component component = table.prepareRenderer(renderer, row, column); rendererPane.paintComponent(g, component, table, cellRect.x, cellRect.y, cellRect.width, cellRect.height, true); } } private void paintCells(final Graphics g, final int rMin, final int rMax, final int cMin, final int cMax) {
private void updateBounds() { if (table == null) { System.err.println("table is null"); return; } if (table.isEditing()) { Rectangle cellRect = table.getCellRect(table.getEditingRow(), table.getEditingColumn(), false); Dimension prefSize = getPreferredSize(); putClientProperty(UPDATE_BOUNDS, Boolean.TRUE); setBounds(getX(), getY(), Math.min(cellRect.width, prefSize.width), Math.max(cellRect.height + prefSize.height, prefSize.height)); putClientProperty(UPDATE_BOUNDS, Boolean.FALSE); validate(); } }
private void paintCell(Graphics g, Rectangle cellRect, int row, int column) { if (table.isEditing() && table.getEditingRow()==row && table.getEditingColumn()==column) { Component component = table.getEditorComponent(); component.setBounds(cellRect); component.validate(); } else { TableCellRenderer renderer = table.getCellRenderer(row, column); Component component = table.prepareRenderer(renderer, row, column); rendererPane.paintComponent(g, component, table, cellRect.x, cellRect.y, cellRect.width, cellRect.height, true); } }
public void actionPerformed(ActionEvent e) { if (grid.isEditing()) { TableCellEditor cellEditor = grid.getCellEditor(grid.getEditingRow(), grid.getEditingColumn()); cellEditor.stopCellEditing(); } tableModel.addRow(defaultValues); tableModel.fireTableDataChanged(); // Enable DELETE (which may already be enabled, but it won't hurt) deleteRowButton.setEnabled(true); // Highlight (select) the appropriate row. int rowToSelect = tableModel.getRowCount() - 1; if (rowToSelect < grid.getRowCount()) { grid.setRowSelectionInterval(rowToSelect, rowToSelect); } sender.updateUI(); } }
@Override public void focusLost(FocusEvent e) { final int editingRow = table.getEditingRow(); final int editingColumn = table.getEditingColumn(); CellEditor ce = null; if (editingRow != -1 && editingColumn != -1) { ce = table.getCellEditor(editingRow,editingColumn); } Component editor = table.getEditorComponent(); if(ce != null && (editor == null || editor != e.getOppositeComponent())) { ce.stopCellEditing(); } else if(editor != null) { editor.addFocusListener(this); } this.firePropertyChange(); }