Package javax.swing.event

Examples of javax.swing.event.TableModelListener


        List rows = new ArrayList();
        rows.add(new Object());
        rows.add(new Object());
       
        //create the mock listeners and add them to the model
        TableModelListener listener1 = (TableModelListener) EasyMock.createMock(TableModelListener.class);
        TableModelListener listener2 = (TableModelListener) EasyMock.createMock(TableModelListener.class);
        model.addTableModelListener(listener1);
        model.addTableModelListener(listener2);
       
        //set the expectations on the mock listeners
        TableModelEvent expectedEvent = new TableModelEvent(model);
        listener1.tableChanged(matchEvent(expectedEvent));
        listener2.tableChanged(matchEvent(expectedEvent));
       
        //switch the mocks to replay mode
        EasyMock.replay(listener1);
        EasyMock.replay(listener2);
       
        //...and execute the test
        model.setRows(rows);
       
        Assert.assertEquals(2, model.getRowCount());
        EasyMock.verify(listener1);
        EasyMock.verify(listener2);
       
        //Create a new list of rows and confirm that it overwrites the existing rows
        List rows2 = new ArrayList(3);
        rows2.add(new Object());
        rows2.add(new Object());
        rows2.add(new Object());
       
        //reset the mocks
        EasyMock.reset(listener1);
        EasyMock.reset(listener2);
       
        //set the expectations on the mock listeners
        listener1.tableChanged(matchEvent(expectedEvent));
        listener2.tableChanged(matchEvent(expectedEvent));
       
        //switch the mocks to replay mode
        EasyMock.replay(listener1);
        EasyMock.replay(listener2);
       
View Full Code Here


     */
    public final void testAddRow() {
       
        MutableTableModel model = getTableModel();
        Object row = new Object();
        TableModelListener listener1 = (TableModelListener) EasyMock.createMock(TableModelListener.class);
        TableModelListener listener2 = (TableModelListener) EasyMock.createMock(TableModelListener.class);
        model.addTableModelListener(listener1);
        model.addTableModelListener(listener2);
       
        try {
            model.addRow(null);
            Assert.fail("Should have thrown an IllegalArgumentException");
        }
        catch (IllegalArgumentException e) {
            //test passes
        }
       
        TableModelEvent event = new TableModelEvent(model,
                                                    0,
                                                    0,
                                                    TableModelEvent.ALL_COLUMNS,
                                                    TableModelEvent.INSERT);
        listener1.tableChanged(matchEvent(event));
        listener2.tableChanged(matchEvent(event));
       
        EasyMock.replay(listener1);
        EasyMock.replay(listener2);
       
        Assert.assertEquals(0, model.getRowCount());
View Full Code Here

     * Tests the {@link MutableTableModel#addRows(java.util.List)} method.
     */
    public final void testAddRows() {
       
        MutableTableModel model = getTableModel();
        TableModelListener listener1 = (TableModelListener) EasyMock.createMock(TableModelListener.class);
        TableModelListener listener2 = (TableModelListener) EasyMock.createMock(TableModelListener.class);
        model.addTableModelListener(listener1);
        model.addTableModelListener(listener2);
      
        try {
            model.addRows(null);
            Assert.fail("Should have thrown an IllegalArgumentException");
        }
        catch (IllegalArgumentException e) {
            //test passes
        }
       
        //Passing an empty list of rows should have no effect on the model or listeners
       
        EasyMock.replay(listener1);
        EasyMock.replay(listener2);
        Assert.assertEquals(0, model.getRowCount());
        model.addRows(new ArrayList());
        Assert.assertEquals(0, model.getRowCount());
        EasyMock.verify(listener1);
        EasyMock.verify(listener2);
       
        //reset the mocks for the next test
        EasyMock.reset(listener1);
        EasyMock.reset(listener2);
       
        List rows = new ArrayList(2);
        rows.add(new Object());
        rows.add(new Object());

        TableModelEvent expectedEvent = new TableModelEvent(model,
                                                            0,
                                                            1,
                                                            TableModelEvent.ALL_COLUMNS,
                                                            TableModelEvent.INSERT);
       
        listener1.tableChanged(matchEvent(expectedEvent));
        listener2.tableChanged(matchEvent(expectedEvent));
       
        EasyMock.replay(listener1);
        EasyMock.replay(listener2);
       
        Assert.assertEquals(0, model.getRowCount());
View Full Code Here

        cTableSatisListesiSilClicked();
      }
    });

    cTableSatisListesi.getModel().addTableModelListener(
        new TableModelListener() {
          @Override
          public void tableChanged(TableModelEvent evt) {
            cTableSatisListesiAdetClicked(evt);
          }
        });
View Full Code Here

      table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
      table.setTableHeader(null);

    }
    // TODO MIGRATE TO A DIFFERENT CLASS - GUI.TABLE.PROBABILISTICTABLEMODEL
    table.getModel().addTableModelListener(new TableModelListener() {
      public void tableChanged(TableModelEvent e) {
        // Change state name or reset to its previous value.
        if (e.getColumn() == 0) {
          if (!table.getValueAt(e.getLastRow(), e.getColumn()).toString().trim().equals("")) {
            node.setStateAt(table.getValueAt(e.getLastRow(),
View Full Code Here

    }

    table.setTableHeader(null);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    table.getModel().addTableModelListener(new TableModelListener() {
      public void tableChanged(TableModelEvent e) {
        if (e.getLastRow() < variables - 1) {
          return;
        }
        if (e.getColumn() == 0) {
View Full Code Here

        cTableSatisListesiSilClicked();
      }
    });

    cTableSatisListesi.getModel().addTableModelListener(
        new TableModelListener() {
          @Override
          public void tableChanged(TableModelEvent evt) {
            cTableSatisListesiAdetClicked(evt);
          }
        });
View Full Code Here

      catch (Throwable ex)
      {
         cat.error(ex.getMessage(), ex);
      }

      propertyTableModel.addTableModelListener(new TableModelListener()
      {
         public void tableChanged(TableModelEvent arg0)
         {
            dialog.setDirty();
         }
View Full Code Here

        tblParameters.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
        tblParameters.setFillsViewportHeight(true);
        defaultTableModel = new DefaultTableModel(new Object[][] { { null, null, null, null }, }, new String[] { "I/O",
                "Parameter Name", "Type", "Description" });
        tblParameters.setModel(defaultTableModel);
        defaultTableModel.addTableModelListener(new TableModelListener() {

            @Override
            public void tableChanged(TableModelEvent arg0) {
                if (!ignoreTableChanges) {
          int selectedRow = tblParameters.getSelectedRow();
View Full Code Here

        tblParameters.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
        tblParameters.setFillsViewportHeight(true);
        defaultTableModel = new DefaultTableModel(new Object[][] { { null, null, null, null }, }, new String[] { "I/O",
                "Parameter Name", "Type", "Description" });
        tblParameters.setModel(defaultTableModel);
        defaultTableModel.addTableModelListener(new TableModelListener() {

            @Override
            public void tableChanged(TableModelEvent arg0) {
                if (!ignoreTableChanges) {
          int selectedRow = tblParameters.getSelectedRow();
View Full Code Here

TOP

Related Classes of javax.swing.event.TableModelListener

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.