Java Code Examples for javax.swing.table.TableModel#removeTableModelListener()
The following examples show how to use
javax.swing.table.TableModel#removeTableModelListener() .
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: PropertySheetTable.java From orbit-image-analysis with GNU General Public License v3.0 | 6 votes |
/** * Overriden to register a listener on the model. This listener * ensures editing is cancelled when editing row is being changed. * * @see javax.swing.JTable#setModel(javax.swing.table.TableModel) * @throws IllegalArgumentException if dataModel is not a * {@link PropertySheetTableModel} */ public void setModel(TableModel newModel) { if (!(newModel instanceof PropertySheetTableModel)) { throw new IllegalArgumentException("dataModel must be of type " + PropertySheetTableModel.class.getName()); } if (cancelEditing == null) { cancelEditing = new CancelEditing(); } TableModel oldModel = getModel(); if (oldModel != null) { oldModel.removeTableModelListener(cancelEditing); } super.setModel(newModel); newModel.addTableModelListener(cancelEditing); // ensure the "value" column can not be resized getColumnModel().getColumn(1).setResizable(false); }
Example 2
Source File: PropertySheetTable.java From CodenameOne with GNU General Public License v2.0 | 6 votes |
/** * Overriden to register a listener on the model. This listener ensures * editing is cancelled when editing row is being changed. * * @see javax.swing.JTable#setModel(javax.swing.table.TableModel) * @throws IllegalArgumentException * if dataModel is not a {@link PropertySheetTableModel} */ public void setModel(TableModel newModel) { if (!(newModel instanceof PropertySheetTableModel)) { throw new IllegalArgumentException("dataModel must be of type " + PropertySheetTableModel.class.getName()); } if (cancelEditing == null) { cancelEditing = new CancelEditing(); } TableModel oldModel = getModel(); if (oldModel != null) { oldModel.removeTableModelListener(cancelEditing); } super.setModel(newModel); newModel.addTableModelListener(cancelEditing); // ensure the "value" column can not be resized getColumnModel().getColumn(1).setResizable(false); }
Example 3
Source File: ReferencePanel.java From ghidra with Apache License 2.0 | 5 votes |
void dispose() { TableModel model = refTable.getModel(); model.removeTableModelListener(listener); threadedTablePanel.dispose(); refTable.dispose(); referenceProvider = null; }
Example 4
Source File: FmtImports.java From netbeans with Apache License 2.0 | 5 votes |
private void separateStaticImportsCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_separateStaticImportsCheckBoxActionPerformed TableModel oldModel = importLayoutTable.getModel(); TableModel newModel = (DefaultTableModel)createTableModel(importGroupsOrder, preferences); importLayoutTable.setModel(newModel); setImportLayoutTableColumnsWidth(); for (TableModelListener l : ((DefaultTableModel)oldModel).getTableModelListeners()) { oldModel.removeTableModelListener(l); newModel.addTableModelListener(l); l.tableChanged(null); } }
Example 5
Source File: NetworkMonitorTopComponent.java From netbeans with Apache License 2.0 | 5 votes |
void setModel(Model model, boolean debuggingSession) { this.model = model; this.debuggingSession = debuggingSession; TableModel tableModel = requestTable.getModel(); if (tableModel != null) { tableModel.removeTableModelListener(this); } requestTable.setModel(model); requestTable.setRowSorter(new TriStateRowSorter(model)); model.addTableModelListener(this); selectedItemChanged(); updateVisibility(); }
Example 6
Source File: JTableEx.java From pcgen with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void setModel(TableModel dataModel) { Objects.requireNonNull(dataModel, "Cannot set a null TableModel"); if (this.dataModel != dataModel) { TableModel old = this.dataModel; if (old != null) { old.removeTableModelListener(this); } this.dataModel = dataModel; dataModel.addTableModelListener(this); tableChanged(new TableModelEvent(dataModel, TableModelEvent.HEADER_ROW)); firePropertyChange("model", old, dataModel); if (getAutoCreateRowSorter()) { if (dataModel instanceof SortableTableModel) { super.setRowSorter(new SortableTableRowSorter((SortableTableModel) dataModel)); } else { super.setRowSorter(new TableRowSorter<>(dataModel)); } } } }
Example 7
Source File: JTableEx.java From pcgen with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void setModel(TableModel dataModel) { Objects.requireNonNull(dataModel, "Cannot set a null TableModel"); if (this.dataModel != dataModel) { TableModel old = this.dataModel; if (old != null) { old.removeTableModelListener(this); } this.dataModel = dataModel; dataModel.addTableModelListener(this); tableChanged(new TableModelEvent(dataModel, TableModelEvent.HEADER_ROW)); firePropertyChange("model", old, dataModel); if (getAutoCreateRowSorter()) { if (dataModel instanceof SortableTableModel) { super.setRowSorter(new SortableTableRowSorter((SortableTableModel) dataModel)); } else { super.setRowSorter(new TableRowSorter<>(dataModel)); } } } }
Example 8
Source File: TableSelectionModel.java From wandora with GNU General Public License v3.0 | 5 votes |
/** * When the TableModel changes, the TableSelectionModel * has to adapt to the new Model. This method is called * if a new TableModel is set to the JTable. */ // implements PropertyChangeListener public void propertyChange(PropertyChangeEvent evt) { if ("model".equals(evt.getPropertyName())) { TableModel newModel = (TableModel)(evt.getNewValue()); setColumns(newModel.getColumnCount()); TableModel oldModel = (TableModel)(evt.getOldValue()); if (oldModel != null) oldModel.removeTableModelListener(this); //TableSelectionModel must be aware of changes in the TableModel newModel.addTableModelListener(this); } }
Example 9
Source File: JoiningTableModel.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
public synchronized void removeTableModel( final TableModel model ) { for ( int i = 0; i < models.size(); i++ ) { final TablePosition position = models.get( i ); if ( position.getTableModel() == model ) { models.remove( position ); model.removeTableModelListener( changeHandler ); updateStructure(); return; } } }
Example 10
Source File: TableRowHeightOptimizer.java From weblaf with GNU General Public License v3.0 | 5 votes |
@Override public void propertyChange ( @NotNull final PropertyChangeEvent event ) { final String propertyName = event.getPropertyName (); if ( Objects.equals ( propertyName, WebLookAndFeel.MODEL_PROPERTY ) ) { // Move table model listener to new model final TableModel oldModel = ( TableModel ) event.getOldValue (); if ( oldModel != null ) { oldModel.removeTableModelListener ( this ); } final TableModel newModel = ( TableModel ) event.getNewValue (); if ( newModel != null ) { newModel.addTableModelListener ( this ); } } else if ( Objects.equals ( propertyName, WebTable.ROW_HEIGHT_PROPERTY ) && !adjusting ) { // Save new row height initialRowHeight = component.getRowHeight (); // Overwrite row height optimizeRowHeight (); } }
Example 11
Source File: UserActivityWatcher.java From consulo with Apache License 2.0 | 5 votes |
public void propertyChange(PropertyChangeEvent evt) { TableModel oldModel = (TableModel)evt.getOldValue(); if (oldModel != null) { oldModel.removeTableModelListener(myTableModelListener); } TableModel newModel = (TableModel)evt.getNewValue(); if (newModel != null) { newModel.addTableModelListener(myTableModelListener); } if (oldModel != null) { fireUIChanged(); } }
Example 12
Source File: UserActivityWatcher.java From consulo with Apache License 2.0 | 5 votes |
protected void unprocessComponent(final Component component) { if (component instanceof JTextComponent) { ((JTextComponent)component).getDocument().removeDocumentListener(myDocumentListener); } else if (component instanceof ItemSelectable) { ((ItemSelectable)component).removeItemListener(myItemListener); } else if (component instanceof JTree) { ((JTree)component).getModel().removeTreeModelListener(myTreeModelListener); } else if (component instanceof DocumentBasedComponent) { ((DocumentBasedComponent)component).getDocument().removeDocumentListener(myIdeaDocumentListener); } if (component instanceof JTable) { component.removePropertyChangeListener(myTableListener); TableModel model = ((JTable)component).getModel(); if (model != null) { model.removeTableModelListener(myTableModelListener); } } if (component instanceof JSlider){ ((JSlider)component).removeChangeListener(myChangeListener); } if (component instanceof UserActivityProviderComponent) { ((UserActivityProviderComponent)component).removeChangeListener(myChangeListener); } }
Example 13
Source File: SheetCell.java From netbeans with Apache License 2.0 | 4 votes |
@Override protected void detachEditor() { super.detachEditor(); TableModel tableModel = outline.getModel(); tableModel.removeTableModelListener(this); }
Example 14
Source File: MappingTable.java From netbeans with Apache License 2.0 | 4 votes |
void removeTableModelListener(TableModelListener tml) { TableModel tableModel = getModel(); if (tableModel != null) { tableModel.removeTableModelListener(tml); } }
Example 15
Source File: DisplayTable.java From netbeans with Apache License 2.0 | 4 votes |
public void removeTableModelListener(TableModelListener tml) { TableModel tableModel = getModel(); if (tableModel != null) { tableModel.removeTableModelListener(tml); } }
Example 16
Source File: TableHelper.java From CodenameOne with GNU General Public License v2.0 | votes |
public static PropertyChangeListener addModelTracker(JTable p_Table, final TableModelListener p_Listener) { PropertyChangeListener propListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { TableModel oldModel = (TableModel) event.getOldValue(); TableModel newModel = (TableModel) event.getNewValue(); if (oldModel != null) oldModel.removeTableModelListener(p_Listener); if (newModel != null) newModel.addTableModelListener(p_Listener); } }; p_Table.addPropertyChangeListener("model", propListener); p_Table.getModel().addTableModelListener(p_Listener); return propListener; }