Example usage for javax.swing.event TableModelEvent TableModelEvent

List of usage examples for javax.swing.event TableModelEvent TableModelEvent

Introduction

In this page you can find the example usage for javax.swing.event TableModelEvent TableModelEvent.

Prototype

public TableModelEvent(TableModel source) 

Source Link

Document

All row data in the table has changed, listeners should discard any state that was based on the rows and requery the TableModel to get the new row count and all the appropriate values.

Usage

From source file:net.sourceforge.jasa.view.OrderBookView.java

public void notifyTableChanged() {
    for (TableModelListener l : listeners) {
        l.tableChanged(new TableModelEvent(this));
    }//from ww w  . j a va2  s  . co m
}

From source file:com.github.fritaly.dualcommander.FileTableModel.java

/**
 * Notifies all listeners that all cell values in the table's
 * rows may have changed. The number of rows may also have changed
 * and the <code>JTable</code> should redraw the
 * table from scratch. The structure of the table (as in the order of the
 * columns) is assumed to be the same.// w  w w.ja v  a2  s.co m
 *
 * @see TableModelEvent
 * @see EventListenerList
 * @see javax.swing.JTable#tableChanged(TableModelEvent)
 */
public void fireTableDataChanged() {
    fireTableChanged(new TableModelEvent(this));
}

From source file:StocksTable5.java

public void retrieveData() {
    SimpleDateFormat frm = new SimpleDateFormat("MM/dd/yyyy");
    String currentDate = frm.format(m_data.m_date);
    String result = (String) JOptionPane.showInputDialog(this, "Please enter date in form mm/dd/yyyy:", "Input",
            JOptionPane.INFORMATION_MESSAGE, null, null, currentDate);
    if (result == null)
        return;/*from   w w  w.j  a  v  a2 s .  c  om*/

    java.util.Date date = null;
    try {
        date = frm.parse(result);
    } catch (java.text.ParseException ex) {
        date = null;
    }

    if (date == null) {
        JOptionPane.showMessageDialog(this, result + " is not a valid date", "Warning",
                JOptionPane.WARNING_MESSAGE);
        return;
    }

    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    switch (m_data.retrieveData(date)) {
    case 0: // Ok with data
        m_title.setText(m_data.getTitle());
        m_table.tableChanged(new TableModelEvent(m_data));
        m_table.repaint();
        break;
    case 1: // No data
        JOptionPane.showMessageDialog(this, "No data found for " + result, "Warning",
                JOptionPane.WARNING_MESSAGE);
        break;
    case -1: // Error
        JOptionPane.showMessageDialog(this, "Error retrieving data", "Warning", JOptionPane.WARNING_MESSAGE);
        break;
    }
    setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}

From source file:com.alvermont.terraj.util.ui.HiddenTableModel.java

/**
 * Add a new set of column values to this table, all null
 *
 * @param name The name of the column//from w w  w .j av a 2  s  .  com
 * @param columnClass The <code>Class</code> that items in this column will be
 */
protected void addColumnValue(String name, Class columnClass) {
    this.columnNames.add(name);
    this.columnsVisible.add(Boolean.TRUE);
    this.columnClasses.add(columnClass);

    for (int r = 0; r < this.data.size(); ++r) {
        final List<Object> l = this.data.get(r);

        l.add(null);
    }

    fireTableChanged(new TableModelEvent(this));
}

From source file:net.sourceforge.jabm.view.JFrameReportVariables.java

public void notifyTableChanged() {
    for (TableModelListener l : listeners) {
        l.tableChanged(new TableModelEvent(this));
    }//from w  w  w. ja v  a 2s.  c  om

}

From source file:com.alvermont.terraj.util.ui.HiddenTableModel.java

/**
 * Add a new set of column values to this table, initialized from a vector
 * of values./*from   w w  w .  j  a  va2  s.  c o  m*/
 *
 * @param name The name of the column
 * @param columnClass The <code>Class</code> that items in this column will be
 * @param values The values to be assigned in the new column, row by row
 */
protected void addColumnValue(String name, Class columnClass, Vector values) {
    this.columnNames.add(name);
    this.columnsVisible.add(Boolean.TRUE);
    this.columnClasses.add(columnClass);

    for (int r = 0; r < this.data.size(); ++r) {
        final List<Object> l = this.data.get(r);

        l.add(values.get(r));
    }

    fireTableChanged(new TableModelEvent(this));
}

From source file:edu.ku.brc.af.ui.forms.RecordSetTableViewObj.java

/**
 * @param recordSet/*from   w  ww.  ja  v a2 s  . co  m*/
 */
private void processRecordSet(final RecordSetIFace recordSet) {
    isLoading = true;

    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            table.tableChanged(new TableModelEvent(model));
            table.repaint();
        }
    });

    DBTableIdMgr.getInstance().getInClause(recordSet);
    DBTableInfo tableInfo = DBTableIdMgr.getInstance().getInfoById(recordSet.getDbTableId());

    DataProviderFactory.getInstance().evict(tableInfo.getClassObj());

    if (tempSession == null) {
        tempSession = DataProviderFactory.getInstance().createSession();
    }

    String sqlStr = DBTableIdMgr.getInstance().getQueryForTable(recordSet);
    if (StringUtils.isNotBlank(sqlStr)) {
        dataObjList.addAll(tempSession.getDataList(sqlStr));

        for (Object obj : dataObjList) {
            FormDataObjIFace fdi = (FormDataObjIFace) obj;
            fdi.forceLoad();
        }
    }

    if (tempSession != null) {
        tempSession.close();
        tempSession = null;
    }

    isLoading = false;

    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            table.repaint();
        }
    });
}

From source file:com.alvermont.terraj.util.ui.HiddenTableModel.java

/**
 * Add a new set of column values to this table, initialized from an
 * array of values.//  ww w  .ja va  2 s . co m
 *
 * @param name The name of the column
 * @param columnClass The <code>Class</code> that items in this column will be
 * @param values The values to be assigned in the new column, row by row
 */
protected void addColumnValue(String name, Class columnClass, Object[] values) {
    this.columnNames.add(name);
    this.columnsVisible.add(Boolean.TRUE);
    this.columnClasses.add(columnClass);

    for (int r = 0; r < this.data.size(); ++r) {
        final List<Object> l = this.data.get(r);

        l.add(values[r]);
    }

    fireTableChanged(new TableModelEvent(this));
}

From source file:blue.soundObject.jmask.ItemList.java

public void addListItem(Double val, int rowIndex) {
    if (rowIndex < 0 || rowIndex >= listItems.size()) {
        listItems.add(val);
    } else {/* w w  w. j ava  2 s. co m*/
        listItems.add(rowIndex, val);
    }

    TableModelEvent tme = new TableModelEvent(this);
    fireTableUpdated(tme);
}

From source file:blue.soundObject.jmask.ItemList.java

public void removeListItem(int rowIndex) {
    listItems.remove(rowIndex);//from  w ww  . ja v  a  2  s  .  co m

    TableModelEvent tme = new TableModelEvent(this);
    fireTableUpdated(tme);
}