Package javax.swing.event

Examples of javax.swing.event.TableModelEvent


    m1.addColumn("C4", columnData1);
    harness.check(m1.getColumnCount(), 4);                 // 1
    harness.check(m1.getColumnName(3), "C4");              // 2
    harness.check(m1.getValueAt(0, 3), "V1");              // 3
    harness.check(m1.getValueAt(1, 3), "V2");              // 4
    TableModelEvent event = listener1.getEvent();
    harness.check(event.getType(), TableModelEvent.UPDATE); // 5
    harness.check(event.getColumn(), TableModelEvent.ALL_COLUMNS); // 6
    harness.check(event.getFirstRow(), -1);                 // 7
    harness.check(event.getLastRow(), -1);                  // 8
   
    // too few data values
    DefaultTableModel m2 = new DefaultTableModel(2, 3);
    MyTableModelListener listener2 = new MyTableModelListener();
    m2.addTableModelListener(listener2);
    Vector columnData2 = new Vector();
    columnData2.add("V1");
    m2.addColumn("C4", columnData2);
    harness.check(m2.getColumnCount(), 4);                 // 9
    harness.check(m2.getColumnName(3), "C4");              // 10
    harness.check(m2.getValueAt(0, 3), "V1");              // 11
    harness.check(m2.getValueAt(1, 3), null);              // 12
    event = listener2.getEvent();
    harness.check(event.getType(), TableModelEvent.UPDATE);
    harness.check(event.getColumn(), TableModelEvent.ALL_COLUMNS);
    harness.check(event.getFirstRow(), -1);
    harness.check(event.getLastRow(), -1);
   
    // too many data values
    DefaultTableModel m3 = new DefaultTableModel(
            new Object[] {"C1", "C2", "C3"}, 2);
    Vector columnData3 = new Vector();
View Full Code Here


    Vector columns = new Vector();
    columns.add("C1");
    columns.add("C2");
    columns.add("C3");
    m.setDataVector(v, columns);
    TableModelEvent event = listener.getEvent();
    harness.check(event.getType(), TableModelEvent.UPDATE);
    harness.check(event.getColumn(), TableModelEvent.ALL_COLUMNS);
    harness.check(event.getFirstRow(), -1);
    harness.check(event.getLastRow(), -1);
  }
View Full Code Here

    m1.addTableModelListener(listener1);
    m1.setValueAt("V1", 0, 0);
    m1.setValueAt("V2", 1, 0);
    m1.setValueAt("V3", 2, 0);
    m1.removeRow(2);
    TableModelEvent event = listener1.getEvent();
    harness.check(event.getColumn(), -1);                    // 6
    harness.check(event.getFirstRow(), 2);                   // 7
    harness.check(event.getLastRow(), 2);                    // 8
    harness.check(event.getType(), TableModelEvent.DELETE)// 9
  }
View Full Code Here

    m1.addTableModelListener(listener1);
    m1.setValueAt("V1", 0, 0);
    m1.setValueAt("V2", 0, 1);
    m1.setValueAt("V3", 0, 2);
    m1.setColumnCount(4);
    TableModelEvent event = listener1.getEvent();
    harness.check(event.getType(), TableModelEvent.UPDATE);
    harness.check(event.getColumn(), TableModelEvent.ALL_COLUMNS);
    harness.check(event.getFirstRow(), -1);
    harness.check(event.getLastRow(), -1);

    DefaultTableModel m2 = new DefaultTableModel(1, 3);
    MyTableModelListener listener2 = new MyTableModelListener();
    m2.addTableModelListener(listener2);
    m2.setValueAt("V1", 0, 0);
    m2.setValueAt("V2", 0, 1);
    m2.setValueAt("V3", 0, 2);
    m2.setColumnCount(1);
    TableModelEvent event2 = listener2.getEvent();
    harness.check(event2.getType(), TableModelEvent.UPDATE);
    harness.check(event.getColumn(), TableModelEvent.ALL_COLUMNS);
    harness.check(event.getFirstRow(), -1);
    harness.check(event.getLastRow(), -1);
  }
View Full Code Here

    MyTableModelListener listener1 = new MyTableModelListener();
    m1.addTableModelListener(listener1);
    m1.insertRow(0, new Object[] {"V1", "V2", "V3"});
    harness.check(m1.getColumnCount(), 3);
    harness.check(m1.getRowCount(), 1);
    TableModelEvent event = listener1.getEvent();
    harness.check(event.getType(), TableModelEvent.INSERT);
    listener1.setEvent(null);
   
    m1.insertRow(0, (Object[]) null);
    harness.check(m1.getRowCount(), 2);
    event = listener1.getEvent();
    harness.check(event.getType(), TableModelEvent.INSERT);
    harness.check(event.getColumn(), TableModelEvent.ALL_COLUMNS);
    harness.check(event.getFirstRow(), 0);
    harness.check(event.getLastRow(), 0);
    listener1.setEvent(null);
   
    // negative row index
    boolean pass = false;
    try
View Full Code Here

    MyTableModelListener listener1 = new MyTableModelListener();
    m1.addTableModelListener(listener1);
    m1.insertRow(0, v1);
    harness.check(m1.getColumnCount(), 3);
    harness.check(m1.getRowCount(), 1);
    TableModelEvent event = listener1.getEvent();
    harness.check(event.getType(), TableModelEvent.INSERT);
    harness.check(event.getColumn(), TableModelEvent.ALL_COLUMNS);
    harness.check(event.getFirstRow(), 0);
    harness.check(event.getLastRow(), 0);
    listener1.setEvent(null);
   
    m1.insertRow(0, (Vector) null);
    harness.check(m1.getRowCount(), 2);
    event = listener1.getEvent();
    harness.check(event.getType(), TableModelEvent.INSERT);
    harness.check(event.getColumn(), TableModelEvent.ALL_COLUMNS);
    harness.check(event.getFirstRow(), 0);
    harness.check(event.getLastRow(), 0);
    listener1.setEvent(null);
   
    // negative row index
    boolean pass = false;
    try
View Full Code Here

  public void testConstructor1(TestHarness harness)
  {
    harness.checkPoint("(TableModel)");
    DefaultTableModel tm = new DefaultTableModel(2, 3);
    TableModelEvent event = new TableModelEvent(tm);
    harness.check(event.getSource() == tm);
    harness.check(event.getType(), TableModelEvent.UPDATE);
    harness.check(event.getColumn(), TableModelEvent.ALL_COLUMNS);
    harness.check(event.getFirstRow(), 0);
    harness.check(event.getLastRow(), Integer.MAX_VALUE);
   
    // try a null argument...
    boolean pass = false;
    try
    {
      /*TableModelEvent e =*/ new TableModelEvent(null);   
    }
    catch (IllegalArgumentException e)
    {
      pass = true;  
    }
View Full Code Here

  public void testConstructor2(TestHarness harness)
  {
    harness.checkPoint("(TableModel, int)");
    DefaultTableModel tm = new DefaultTableModel(2, 3);
    TableModelEvent event = new TableModelEvent(tm, 1);
    harness.check(event.getSource() == tm);
    harness.check(event.getType(), TableModelEvent.UPDATE);
    harness.check(event.getColumn(), TableModelEvent.ALL_COLUMNS);
    harness.check(event.getFirstRow(), 1);
    harness.check(event.getLastRow(), 1);
   
    // try a null argument...
    boolean pass = false;
    try
    {
      /*TableModelEvent e =*/ new TableModelEvent(null, 1);   
    }
    catch (IllegalArgumentException e)
    {
      pass = true;  
    }
View Full Code Here

  public void testConstructor3(TestHarness harness)
  {
    harness.checkPoint("(TableModel, int, int)");
    DefaultTableModel tm = new DefaultTableModel(2, 3);
    TableModelEvent event = new TableModelEvent(tm, 0, 2);
    harness.check(event.getSource() == tm);
    harness.check(event.getType(), TableModelEvent.UPDATE);
    harness.check(event.getColumn(), TableModelEvent.ALL_COLUMNS);
    harness.check(event.getFirstRow(), 0);
    harness.check(event.getLastRow(), 2);
   
    // try a null argument...
    boolean pass = false;
    try
    {
      /*TableModelEvent e =*/ new TableModelEvent(null, 1, 1);   
    }
    catch (IllegalArgumentException e)
    {
      pass = true;  
    }
    harness.check(pass);
   
    // try first row > lastRow
    pass = false;
    TableModelEvent e = new TableModelEvent(tm, 2, 0);
    harness.check(e.getFirstRow(), 2);
    harness.check(e.getLastRow(), 0);
  }
View Full Code Here

  public void testConstructor4(TestHarness harness)
  {
    harness.checkPoint("(TableModel, int, int, int)");
    DefaultTableModel tm = new DefaultTableModel(2, 3);
    TableModelEvent event = new TableModelEvent(tm, 0, 2, 1);
    harness.check(event.getSource() == tm);
    harness.check(event.getType(), TableModelEvent.UPDATE);
    harness.check(event.getColumn(), 1);
    harness.check(event.getFirstRow(), 0);
    harness.check(event.getLastRow(), 2);
   
    // try a null argument...
    boolean pass = false;
    try
    {
      /*TableModelEvent e =*/ new TableModelEvent(null, 1, 1, 0);   
    }
    catch (IllegalArgumentException e)
    {
      pass = true;  
    }
View Full Code Here

TOP

Related Classes of javax.swing.event.TableModelEvent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.