List of usage examples for javax.swing.event TableModelEvent getLastRow
public int getLastRow()
From source file:Main.java
public void tableChanged(TableModelEvent e) { int firstRow = e.getFirstRow(); int lastRow = e.getLastRow(); int index = e.getColumn(); switch (e.getType()) { case TableModelEvent.INSERT: for (int i = firstRow; i <= lastRow; i++) { System.out.println(i); }/* w w w. j a va 2 s .com*/ break; case TableModelEvent.UPDATE: if (firstRow == TableModelEvent.HEADER_ROW) { if (index == TableModelEvent.ALL_COLUMNS) { System.out.println("A column was added"); } else { System.out.println(index + "in header changed"); } } else { for (int i = firstRow; i <= lastRow; i++) { if (index == TableModelEvent.ALL_COLUMNS) { System.out.println("All columns have changed"); } else { System.out.println(index); } } } break; case TableModelEvent.DELETE: for (int i = firstRow; i <= lastRow; i++) { System.out.println(i); } break; } }
From source file:org.nuclos.client.ui.collect.SubForm.java
public void setupTableModelListener() { this.tblmdllistener = new TableModelListener() { @Override/* www . ja v a 2 s .c om*/ public void tableChanged(TableModelEvent ev) { // recalculate the optimal column widths when custom column widths are not used yet and // a row is inserted (the first time): //@todo: this here is entered not only the first time a row is entered but also on startup (sort fires a tableDataChanged) if (!useCustomColumnWidths) { // Now this is an example for an API that sucks :( final boolean bRowsInserted = (ev.getType() == TableModelEvent.INSERT) || // @todo: The first condition (INSERT) is clear, but what for the second (complete UPDATE)? (ev.getType() == TableModelEvent.UPDATE && ev.getColumn() == TableModelEvent.ALL_COLUMNS && ev.getLastRow() == Integer.MAX_VALUE); if (bRowsInserted) { resetDefaultColumnWidths(); LOG.debug("Custom column widths should be used here."); // Setting them manually."); } } // TableModelEvents caused by sorting don't change the subform state: if (!(ev instanceof SortableTableModelEvent)) { fireStateChanged(); } } }; subformtbl.getModel().addTableModelListener(this.tblmdllistener); }
From source file:org.wings.STable.java
public void tableChanged(TableModelEvent e) { // kill active editors //editingCanceled(null); if (e == null || e.getFirstRow() == TableModelEvent.HEADER_ROW) { // The whole thing changed clearSelectionAndLeadAnchor();//w w w .j a v a 2 s. c o m if (getAutoCreateColumnsFromModel()) createDefaultColumnsFromModel(); } else { switch (e.getType()) { case TableModelEvent.INSERT: if (e.getFirstRow() >= 0) getSelectionModel().insertIndexInterval(e.getFirstRow(), e.getLastRow(), true); break; case TableModelEvent.DELETE: if (e.getFirstRow() >= 0) getSelectionModel().removeIndexInterval(e.getFirstRow(), e.getLastRow()); break; case TableModelEvent.UPDATE: /* event fire on javax.swing.table.AbstractTableModel.fireTableDataChanged() */ if (e.getLastRow() == Integer.MAX_VALUE) clearSelectionAndLeadAnchor(); break; } } if (model.getRowCount() != rowCountBackUp) { rowCountBackUp = model.getRowCount(); fireViewportChanged(false); } if (columnModel.getColumnCount() != columnCountBackUp) { columnCountBackUp = columnModel.getColumnCount(); fireViewportChanged(true); } if (e != null && e.getFirstRow() == e.getLastRow() && e.getFirstRow() != TableModelEvent.HEADER_ROW && e.getColumn() != TableModelEvent.ALL_COLUMNS && e.getType() == TableModelEvent.UPDATE) { if (isUpdatePossible() && STable.class.isAssignableFrom(getClass())) update(((TableCG) getCG()).getRenderCellUpdate(this, e.getFirstRow(), e.getColumn())); else reload(); } /* else if (e != null && e.getFirstRow() == 0 && e.getLastRow() == Integer.MAX_VALUE && e.getColumn() == TableModelEvent.ALL_COLUMNS && e.getType() == TableModelEvent.UPDATE) { update(((TableCG)getCG()).getDataUpdate(this)); }*/ else { reload(); } }
From source file:org.yccheok.jstock.gui.JStock.java
private javax.swing.event.TableModelListener getTableModelListener() { return new javax.swing.event.TableModelListener() { @Override// w ww . j a v a2 s . co m public void tableChanged(javax.swing.event.TableModelEvent e) { int firstRow = e.getFirstRow(); int lastRow = e.getLastRow(); int mColIndex = e.getColumn(); switch (e.getType()) { case javax.swing.event.TableModelEvent.INSERT: break; case javax.swing.event.TableModelEvent.UPDATE: break; case javax.swing.event.TableModelEvent.DELETE: break; } } }; }