Java Code Examples for javax.swing.event.TableModelListener

The following examples show how to use javax.swing.event.TableModelListener. These examples are extracted from open source projects. 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 Project: meka   Source File: DataTableModel.java    License: GNU General Public License v3.0 7 votes vote down vote up
/**
 * notfies all listener of the change of the model
 *
 * @param e the event to send to the listeners
 */
public void notifyListener(TableModelEvent e) {
	Iterator<TableModelListener> iter;
	TableModelListener l;

	// is notification enabled?
	if (!isNotificationEnabled()) {
		return;
	}

	iter = m_Listeners.iterator();
	while (iter.hasNext()) {
		l = iter.next();
		l.tableChanged(e);
	}
}
 
Example 2
public void setTraceTableModel(TraceTableModel traceTableModel) {

        this.traceTableModel = traceTableModel;
        this.traceTableModel.addTableModelListener(new TableModelListener() {

            @Override
            public void tableChanged(TableModelEvent tableModelEvent) {

                DefaultTreeTableTree defaultTreeTableTree = getTree();

                AbstractTreeTableTreeModel abstractTreeTableTreeModel;
                abstractTreeTableTreeModel = (AbstractTreeTableTreeModel) defaultTreeTableTree.getModel();

                // in case of search action, just refresh. reload causes
                // collapsing of tree.
                if (tableModelEvent instanceof SearchTableModelEvent) {
                    abstractTreeTableTreeModel.nodeChanged(getRoot());
                } else {
                    if (tableModelEvent.getType() == TableModelEvent.UPDATE) {
                        abstractTreeTableTreeModel.reload();
                    }
                }
            }
        });
    }
 
Example 3
/**
    * Update the Correlation model Parameters Table.
    */
private void updateCorrelationModelParametersTable() {
	// Populate the correlation model parameters table.
	FunctionParameterTableModel parameterTableModel = new FunctionParameterTableModel(this.currentAutoCorrelationFunctionContext);

	this.parentController.getMainPanel().getAutoCorrelationParameterAndGraphPanel().getParametersTable()
	        .setModel(parameterTableModel);

	//setup cell editor.
   	TableColumn columnValue = parentController.getMainPanel().getAutoCorrelationParameterAndGraphPanel()
   	    .getParametersTable().getColumnModel().getColumn(FunctionParameterTableModel.COLUMN_VALUE);
   	columnValue.setCellEditor(new TextCellEditor());

	parameterTableModel.addTableModelListener(new TableModelListener() {
		public void tableChanged(TableModelEvent e) {
			updateCorrelationModelGraph();
		}
	});
}
 
Example 4
/**
 * Adding column is done by creating new model by modifying older one.<p>
 *
 * Insert new column if column is outside the <code>limit</code> Adds new
 * column if selected column inside the <code>limit</code>[email protected] _table
 * target table
 *
 * @param limit the range to avoid inserting
 */
static void addcol(JTable table, int limit) {
    try {
        int sc = table.getSelectedColumn();
        if (sc < limit - 1) {
            sc = table.getColumnCount() - 1;
        }

        DefaultTableModel tableM = (DefaultTableModel) table.getModel();
        DefaultTableModel tableM1 = new DefaultTableModel();
        TableModelListener[] listeners = tableM.getTableModelListeners();

        tableM1.setDataVector(newvectoraddcol(tableM.getDataVector(), sc), getColumnIdentifiersaddcol(sc + 1, table));
        table.setModel(tableM1);
        for (TableModelListener l : listeners) {
            tableM1.addTableModelListener(l);
        }

    } catch (Exception ex) {
        Logger.getLogger(JtableUtils.class.getName()).log(Level.SEVERE, null, ex);
    }

}
 
Example 5
Source Project: netbeans   Source File: EventBroadcaster.java    License: Apache License 2.0 6 votes vote down vote up
/** Fires multiple table model events, setting the inMultiEvent flag
 * as appropriate. */
private void fireTableChange (TableModelEvent[] e) {
    //Event may be null for offscreen info, etc.
    if (e == null || e.length==0) {
        return;
    }
    
    TableModelListener[] listeners = getTableModelListeners();
    inMultiEvent = e.length > 1;
    //System.err.println("fireTableChange("+Arrays.toString(e)+")");
    try {
        for (int i=0; i < e.length; i++) {
            if (i == e.length-1) {
                inMultiEvent = false;
            }
            fireTableChange (e[i], listeners);
        }
    } finally {
        inMultiEvent = false;
    }
}
 
Example 6
@Override
protected void customizeParametersTable(TableView<CSharpParameterTableModelItem> table)
{
	final JTable t = table.getComponent();
	final TableColumn defaultValue = t.getColumnModel().getColumn(2);
	final TableColumn varArg = t.getColumnModel().getColumn(3);
	t.removeColumn(defaultValue);
	t.removeColumn(varArg);
	t.getModel().addTableModelListener(new TableModelListener()
	{
		@Override
		public void tableChanged(TableModelEvent e)
		{
			if(e.getType() == TableModelEvent.INSERT)
			{
				t.getModel().removeTableModelListener(this);
				final TableColumnAnimator animator = new TableColumnAnimator(t);
				animator.setStep(48);
				animator.addColumn(defaultValue, (t.getWidth() - 48) / 3);
				animator.addColumn(varArg, 48);
				animator.startAndDoWhenDone(new Runnable()
				{
					@Override
					public void run()
					{
						t.editCellAt(t.getRowCount() - 1, 0);
					}
				});
				animator.start();
			}
		}
	});
}
 
Example 7
Source Project: netbeans   Source File: RunPortBindingsVisual.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Creates new form RunNetworkVisual
 */
public RunPortBindingsVisual(DockerImageDetail info) {
    initComponents();
    this.info = info;

    addExposedButton.setEnabled(info != null && !info.getExposedPorts().isEmpty());
    portMappingTable.setModel(model);
    UiUtils.configureRowHeight(portMappingTable);

    TableColumn typeColumn = portMappingTable.getColumnModel().getColumn(0);
    JComboBox typeCombo = new JComboBox(ExposedPort.Type.values());
    typeColumn.setCellEditor(new DefaultCellEditor(typeCombo));
    typeColumn.setPreferredWidth(typeColumn.getPreferredWidth() / 2);

    TableColumn portColumn = portMappingTable.getColumnModel().getColumn(2);
    portColumn.setCellRenderer(new CellRenderer("<random>", false));

    TableColumn addressColumn = portMappingTable.getColumnModel().getColumn(3);
    JComboBox addressCombo = new JComboBox(UiUtils.getAddresses(false, false).toArray());
    addressCombo.setEditable(true);
    addressColumn.setCellEditor(new DefaultCellEditor(addressCombo));
    addressColumn.setCellRenderer(new CellRenderer("<any>", false));
    addressColumn.setPreferredWidth(addressColumn.getPreferredWidth() * 2);

    portMappingTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
    model.addTableModelListener(new TableModelListener() {
        @Override
        public void tableChanged(TableModelEvent e) {
            changeSupport.fireChange();
        }
    });
}
 
Example 8
Source Project: ghidra   Source File: TestTableModel.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void fireTableDataChanged() {
	TableModelEvent event = new TableModelEvent(this);
	for (TableModelListener listener : listeners) {
		listener.tableChanged(event);
	}
}
 
Example 9
Source Project: beautyeye   Source File: TableDemo.java    License: Apache License 2.0 5 votes vote down vote up
protected Container createStatusBar() {
	statusLabelString = getString("TableDemo.rowCountLabel", "Showing ");
	searchLabelString = getString("TableDemo.searchCountLabel",
			"Search found ");

	Box statusBar = Box.createHorizontalBox();

	// Left status area
	statusBar.add(Box.createRigidArea(new Dimension(10, 22)));
	statusBarLeft = Box.createHorizontalBox();
	statusBar.add(statusBarLeft);
	actionStatus = new JLabel(getString("TableDemo.noDataStatusLabel",
			"No data loaded"));
	actionStatus.setHorizontalAlignment(JLabel.LEADING);
	statusBarLeft.add(actionStatus);

	// Middle (should stretch)
	statusBar.add(Box.createHorizontalGlue());
	statusBar.add(Box.createHorizontalGlue());
	statusBar.add(Box.createVerticalGlue());

	// Right status area
	tableStatus = new JLabel(statusLabelString + "0");
	statusBar.add(tableStatus);
	statusBar.add(Box.createHorizontalStrut(12));

	// <snip>Track number of rows currently displayed
	oscarModel.addTableModelListener(new TableModelListener() {
		public void tableChanged(TableModelEvent e) {
			// Get rowCount from *table*, not model, as the view row count
			// may be different from the model row count due to filtering
			tableStatus.setText((hasFilterString() ? searchLabelString
					: statusLabelString) + oscarTable.getRowCount());
		}
	});
	// </snip>

	return statusBar;
}
 
Example 10
Source Project: netbeans   Source File: SwingInterop.java    License: Apache License 2.0 5 votes vote down vote up
private BarChart createBarChart() {
    CategoryAxis xAxis = new CategoryAxis();
    xAxis.setCategories(FXCollections.<String>observableArrayList(tableModel.getColumnNames()));
    xAxis.setLabel("Year");

    double tickUnit = tableModel.getTickUnit();

    NumberAxis yAxis = new NumberAxis();
    yAxis.setTickUnit(tickUnit);
    yAxis.setLabel("Units Sold");

    final BarChart chart = new BarChart(xAxis, yAxis, tableModel.getBarChartData());
    tableModel.addTableModelListener(new TableModelListener() {

        public void tableChanged(TableModelEvent e) {
            if (e.getType() == TableModelEvent.UPDATE) {
                final int row = e.getFirstRow();
                final int column = e.getColumn();
                final Object value = ((SampleTableModel) e.getSource()).getValueAt(row, column);

                Platform.runLater(new Runnable() {
                    public void run() {
                        XYChart.Series<String, Number> s = (XYChart.Series<String, Number>) chart.getData().get(row);
                        BarChart.Data data = s.getData().get(column);
                        data.setYValue(value);
                    }
                });
            }
        }
    });
    return chart;
}
 
Example 11
public Example_8_View() {
    super();
    setTitle(getClass().getSimpleName() + " " + ManagementFactory.getRuntimeMXBean().getName());

    setBounds(100, 100, 700, 500);
    setDefaultCloseOperation(StrictThreadingJFrame.EXIT_ON_CLOSE);
    getContentPane().setLayout(new BorderLayout(0, 0));

    final JXTable table = new JXTable(myTableModel);
    table.setHighlighters(HighlighterFactory.createSimpleStriping());
    table.setSortable(false);
    table.getTableHeader().setReorderingAllowed(false);

    myTableModel.addTableModelListener(new TableModelListener() {

        int lastRowCountScrolledTo = -1;

        @Override
        public void tableChanged(final TableModelEvent e) {
            if (TableUtilities.isInsert(e)) {
                final int currentRowCount = myTableModel.getRowCount();
                if (currentRowCount != lastRowCountScrolledTo) {
                    lastRowCountScrolledTo = currentRowCount;
                    SwingUtilities.invokeLater(() -> table.scrollRectToVisible(table.getCellRect(myTableModel.getRowCount() - 1, 0, false)));
                }
            }
        }
    });

    JScrollPane scrollPane = new JScrollPane(table);
    getContentPane().add(scrollPane, BorderLayout.CENTER);
}
 
Example 12
Source Project: netbeans-mmd-plugin   Source File: KeyShortCutEditPanel.java    License: Apache License 2.0 5 votes vote down vote up
private void updateCurrentSelectedForKey (final KeyEvent evt) {
  final int index = this.tableKeyShortcuts.getSelectedRow();
  if (index>=0){
    final KeyShortcut oldShortcut = this.listOfKeys.get(index);
    final int keyCode = evt.getKeyCode();
    final int modifiers = evt.getModifiers() & (KeyEvent.META_MASK | KeyEvent.SHIFT_MASK | KeyEvent.CTRL_MASK | KeyEvent.ALT_MASK);
    final KeyShortcut newShortCut = new KeyShortcut(oldShortcut.getID(),keyCode,modifiers);
    this.listOfKeys.set(index, newShortCut);
    for(final TableModelListener l:this.listeners){
      l.tableChanged(new TableModelEvent(this,index));
    }
  }
  
  updateForSelected();
}
 
Example 13
private void setupTableModelListener() {
//add listener which responds to tableChanged that is fired
//by correlationTableModel.setValueAt().
      this.correlationTableModel.addTableModelListener(new TableModelListener() {
      	public void tableChanged(TableModelEvent e) {
      		//(re)select row after setValueAt was called.

      		//select row of currentCorrelationContext.
      		int selectedRowIndex = correlationTableModel.getCurrentRow();
      		setSelectedRow(selectedRowIndex);
      	}
      });
  }
 
Example 14
Source Project: netbeans-mmd-plugin   Source File: KeyShortCutEditPanel.java    License: Apache License 2.0 5 votes vote down vote up
private void updateCurrentSelectedForKey (final KeyEvent evt) {
  final int index = this.tableKeyShortcuts.getSelectedRow();
  if (index>=0){
    final KeyShortcut oldShortcut = this.listOfKeys.get(index);
    final int keyCode = evt.getKeyCode();
    final int modifiers = evt.getModifiers() & (KeyEvent.META_MASK | KeyEvent.SHIFT_MASK | KeyEvent.CTRL_MASK | KeyEvent.ALT_MASK);
    final KeyShortcut newShortCut = new KeyShortcut(oldShortcut.getID(),keyCode,modifiers);
    this.listOfKeys.set(index, newShortCut);
    for(final TableModelListener l:this.listeners){
      l.tableChanged(new TableModelEvent(this,index));
    }
  }
  
  updateForSelected();
}
 
Example 15
/**
 * Creates a new {@link TablePanel} instance.
 *
 * @param model
 * @param useScrollPane
 *            if set to <code>true</code>, will add a scrollpane around the GUI.
 * @param hideUnavailableContentAssist
 *            if <code>true</code>, the content assist button will be hidden if no content
 *            assist is available for the given field
 */
public TablePanel(final TablePanelModel model, boolean useScrollPane, boolean hideUnavailableContentAssist) {
	this.mapOfComponents = new HashMap<>();
	this.useScrollPane = useScrollPane;
	this.hideUnavailableContentAssist = hideUnavailableContentAssist;
	this.listener = new TableModelListener() {

		@Override
		public void tableChanged(TableModelEvent e) {
			// table structure changed, re-create it
			if (e.getFirstRow() == TableModelEvent.HEADER_ROW) {
				createGUI();
			} else {
				updateComponent(e.getFirstRow(), e.getColumn());
			}
		}
	};

	SwingUtilities.invokeLater(new Runnable() {

		@Override
		public void run() {
			initGUI();
			setModel(model);
		}

	});
}
 
Example 16
Source Project: marathonv5   Source File: SwingInterop.java    License: Apache License 2.0 5 votes vote down vote up
private BarChart createBarChart() {
    CategoryAxis xAxis = new CategoryAxis();
    xAxis.setCategories(FXCollections.<String>observableArrayList(tableModel.getColumnNames()));
    xAxis.setLabel("Year");

    double tickUnit = tableModel.getTickUnit();

    NumberAxis yAxis = new NumberAxis();
    yAxis.setTickUnit(tickUnit);
    yAxis.setLabel("Units Sold");

    final BarChart chart = new BarChart(xAxis, yAxis, tableModel.getBarChartData());
    tableModel.addTableModelListener(new TableModelListener() {

        public void tableChanged(TableModelEvent e) {
            if (e.getType() == TableModelEvent.UPDATE) {
                final int row = e.getFirstRow();
                final int column = e.getColumn();
                final Object value = ((SampleTableModel) e.getSource()).getValueAt(row, column);

                Platform.runLater(new Runnable() {
                    public void run() {
                        XYChart.Series<String, Number> s = (XYChart.Series<String, Number>) chart.getData().get(row);
                        BarChart.Data data = s.getData().get(column);
                        data.setYValue(value);
                    }
                });
            }
        }
    });
    return chart;
}
 
Example 17
Source Project: netbeans   Source File: FmtImports.java    License: Apache License 2.0 5 votes vote down vote up
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 18
Source Project: Digital   Source File: ValueTableModel.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public void hasChanged() {
    SwingUtilities.invokeLater(() -> {
        TableModelEvent tme = new TableModelEvent(this);
        for (TableModelListener l : listeners)
            l.tableChanged(tme);
    });
}
 
Example 19
@Override
public void removeTableModelListener(TableModelListener l) {
}
 
Example 20
Source Project: constellation   Source File: MappingPanel.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void removeTableModelListener(final TableModelListener l) {
    // Required for TableModel, Intentionally left blank
}
 
Example 21
Source Project: jdk8u_jdk   Source File: TableSorter.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override
public void removeTableModelListener(TableModelListener l) {
    evtListenerList.remove(l);
    super.removeTableModelListener(l);
}
 
Example 22
@Override
public void removeTableModelListener(TableModelListener l) {
	// Ignore listeners: no value changes anyway
}
 
Example 23
Source Project: Digital   Source File: ValueTableModel.java    License: GNU General Public License v3.0 4 votes vote down vote up
@Override
public void removeTableModelListener(TableModelListener l) {
    listeners.remove(l);
}
 
Example 24
Source Project: snap-desktop   Source File: TablePagePanel.java    License: GNU General Public License v3.0 4 votes vote down vote up
@Override
public void addTableModelListener(TableModelListener listener) {
    listeners.add(listener);
}
 
Example 25
Source Project: netbeans   Source File: DisplayTable.java    License: Apache License 2.0 4 votes vote down vote up
public void addTableModelListener(TableModelListener tml) {
TableModel tableModel = getModel();
if (tableModel != null) {
    tableModel.addTableModelListener(tml);
}
   }
 
Example 26
Source Project: NBANDROID-V2   Source File: DeviceIpListTablemodel.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void addTableModelListener(TableModelListener l) {
}
 
Example 27
Source Project: gdax-java   Source File: OrderBookModel.java    License: MIT License 4 votes vote down vote up
public void removeTableModelListener(TableModelListener l) {
    listenerList.remove(TableModelListener.class, l);
}
 
Example 28
Source Project: netbeans   Source File: MappingTable.java    License: Apache License 2.0 4 votes vote down vote up
void addTableModelListener(TableModelListener tml) {
    TableModel tableModel = getModel();
    if (tableModel != null) {
        tableModel.addTableModelListener(tml);
    }
}
 
Example 29
Source Project: swift-k   Source File: AppTasksModel.java    License: Apache License 2.0 4 votes vote down vote up
public void addTableModelListener(TableModelListener l) {
}
 
Example 30
Source Project: hottub   Source File: TableSorter.java    License: GNU General Public License v2.0 4 votes vote down vote up
private void removeListeners() {
    for(TableModelListener tnl : evtListenerList)
        super.removeTableModelListener(tnl);
}