Java Code Examples for javax.swing.table.TableCellEditor#isCellEditable()
The following examples show how to use
javax.swing.table.TableCellEditor#isCellEditable() .
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: EditableTableHeader.java From rapidminer-studio with GNU Affero General Public License v3.0 | 6 votes |
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; }
Example 2
Source File: EditableHeader.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
public boolean editCellAt( final int index, final EventObject e ) { if ( cellEditor != null && !cellEditor.stopCellEditing() ) { return false; } if ( !isCellEditable( index ) ) { return false; } final 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; }
Example 3
Source File: EditableHeader.java From chipster with MIT License | 6 votes |
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; }
Example 4
Source File: DelegatingCellEditor.java From netbeans with Apache License 2.0 | 5 votes |
@Override public boolean isCellEditable(EventObject anEvent) { if (!(anEvent.getSource() instanceof Outline)) { return false; } Outline outline = (Outline) anEvent.getSource(); int row; if (anEvent instanceof MouseEvent) { MouseEvent event = (MouseEvent) anEvent; Point p = event.getPoint(); // Locate the editor under the event location //int column = outline.columnAtPoint(p); row = outline.rowAtPoint(p); } else { row = outline.getSelectedRow(); } Node n = DelegatingCellRenderer.getNodeAt(outline, row); if (n instanceof TreeModelNode) { TreeModelNode tmn = (TreeModelNode) n; TableRendererModel trm = tmn.getModel(); try { boolean canEdit = trm.canEditCell(tmn.getObject(), columnID); if (canEdit) { TableCellEditor tce = trm.getCellEditor(tmn.getObject(), columnID); canEdit = tce.isCellEditable(anEvent); return canEdit; } } catch (UnknownTypeException ex) { } } return defaultEditor.isCellEditable(anEvent); }
Example 5
Source File: PropertyTable.java From rapidminer-studio with GNU Affero General Public License v3.0 | 5 votes |
/** * 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; }