Package javax.swing.event

Examples of javax.swing.event.TreeSelectionEvent


            for (int counter = 0; counter < cPathCount; counter++) {
                newness[counter] = isNew;
            }

            TreeSelectionEvent event = new TreeSelectionEvent
                    (this, changedPaths, newness, oldLeadSelection, leadPath);

            fireValueChanged(event);
        }
    }
View Full Code Here


    harness.checkPoint("(Object, TreePath, boolean, TreePath, TreePath)");
    TreeSelectionModel m = new DefaultTreeSelectionModel();
    TreePath p1 = new TreePath("A");
    TreePath p2 = new TreePath("B");
    TreePath p3 = new TreePath("C");
    TreeSelectionEvent tse = new TreeSelectionEvent(m, p1, true, p2, p3);
    harness.check(tse.getSource(), m);
    harness.check(tse.getPath(), p1);
    harness.check(tse.getPaths().length, 1);
    harness.check(tse.getPaths()[0], p1);
    harness.check(tse.isAddedPath());
    harness.check(tse.getOldLeadSelectionPath(), p2);
    harness.check(tse.getNewLeadSelectionPath(), p3);
   
    // check null source
    boolean pass = false;
    try
    {
      tse = new TreeSelectionEvent(null, p1, true, p2, p3);
    }
    catch (IllegalArgumentException e)
    {
      pass = true;
    }
    harness.check(pass);
   
    // check null path
    tse = new TreeSelectionEvent(m, null, true, p2, p3);
    harness.check(tse.getPath(), null);
    harness.check(tse.getPaths().length, 1);
    harness.check(tse.getPaths()[0], null);
   
    // check null old path
    tse = new TreeSelectionEvent(m, p1, true, null,  p3);
    harness.check(tse.getOldLeadSelectionPath(), null);
   
    // check null new path
    tse = new TreeSelectionEvent(m, p1, true, p2, null);
    harness.check(tse.getNewLeadSelectionPath(), null);
  }
View Full Code Here

    TreePath p1B = new TreePath("AA");
    TreePath[] p1 = new TreePath[] {p1A, p1B};
    TreePath p2 = new TreePath("B");
    TreePath p3 = new TreePath("C");
    boolean[] b = new boolean[] {true, false};
    TreeSelectionEvent tse = new TreeSelectionEvent(m, p1, b, p2, p3);
    harness.check(tse.getSource(), m);
    harness.check(tse.getPath(), p1A);
    harness.check(tse.getPaths().length, 2);
    harness.check(tse.getPaths()[0], p1A);
    harness.check(tse.getPaths()[1], p1B);
    harness.check(tse.isAddedPath(), true);
    harness.check(tse.isAddedPath(0), true);
    harness.check(tse.isAddedPath(1), false);
    harness.check(tse.getOldLeadSelectionPath(), p2);
    harness.check(tse.getNewLeadSelectionPath(), p3);
   
    // check null source
    boolean pass = false;
    try
    {
      tse = new TreeSelectionEvent(null, p1, b, p2, p3);
    }
    catch (IllegalArgumentException e)
    {
      pass = true;
    }
    harness.check(pass);
   
    // check null path array
    tse = new TreeSelectionEvent(m, null, b, p2, p3);
   
    // ...constructor allows it, but then fails at getPath()
    pass = false;
    try
      {
        tse.getPath();
      }
    catch (NullPointerException e)
      {
        pass = true;
      }
    harness.check(pass);
    pass = false;
    try
    {
      tse.getPaths();
    }
    catch (NullPointerException e)
    {
      pass = true;
    }
    harness.check(pass);
       
    // check null boolean array
    tse = new TreeSelectionEvent(m, p1, null, p2, p3);
    pass = false;
    try
      {
        tse.isAddedPath();
      }
    catch (NullPointerException e)
      {
        pass = true;
      }
    harness.check(pass);
   
    pass = false;
    try
      {
        tse.isAddedPath(0);
      }
    catch (NullPointerException e)
      {
        pass = true
      }
    harness.check(pass);
   
    // check null old path
    tse = new TreeSelectionEvent(m, p1, b, null,  p3);
    harness.check(tse.getOldLeadSelectionPath(), null);
   
    // check null new path
    tse = new TreeSelectionEvent(m, p1, b, p2, null);
    harness.check(tse.getNewLeadSelectionPath(), null);
  }
View Full Code Here

    TreeSelectionModel m1 = new DefaultTreeSelectionModel();
    TreeSelectionModel m2 = new DefaultTreeSelectionModel();
    TreePath p1 = new TreePath("A");
    TreePath p2 = new TreePath("B");
    TreePath p3 = new TreePath("C");
    TreeSelectionEvent tse1 = new TreeSelectionEvent(m1, p1, true, p2, p3);
    TreeSelectionEvent tse2 = (TreeSelectionEvent) tse1.cloneWithSource(m2);
    harness.check(tse2.getSource(), m2);
    harness.check(tse2.getPath(), p1);
    harness.check(tse2.getPaths().length, 1);
    harness.check(tse2.getPaths()[0], p1);
    harness.check(tse2.isAddedPath());
    harness.check(tse2.getOldLeadSelectionPath(), p2);
    harness.check(tse2.getNewLeadSelectionPath(), p3);
   
    // try null source
    boolean pass = false;
    try
    {
View Full Code Here

  public void checkMethod1(TestHarness harness)
  {
    harness.checkPoint("()");
    TreeSelectionModel m = new DefaultTreeSelectionModel();
    TreePath p1 = new TreePath("A");
    TreeSelectionEvent tse = new TreeSelectionEvent(m, p1, false, null, null);
    harness.check(tse.isAddedPath(), false);
  }
View Full Code Here

    TreeSelectionModel m = new DefaultTreeSelectionModel();
    TreePath p1A = new TreePath("A");
    TreePath p1B = new TreePath("AA");
    TreePath[] p1 = new TreePath[] {p1A, p1B};
    boolean[] b = new boolean[] {true, false};
    TreeSelectionEvent tse = new TreeSelectionEvent(m, p1, b, null, null);
    harness.check(tse.isAddedPath(), true);
    harness.check(tse.isAddedPath(0), true);
    harness.check(tse.isAddedPath(1), false);
  }
View Full Code Here

    TreeSelectionModel m = new DefaultTreeSelectionModel();
    TreePath p1A = new TreePath("A");
    TreePath p1B = new TreePath("AA");
    TreePath[] p1 = new TreePath[] {p1A, p1B};
    boolean[] b = new boolean[] {true, false};
    TreeSelectionEvent tse = new TreeSelectionEvent(m, p1, b, null, null);
    harness.check(tse.isAddedPath(p1A), true);
    harness.check(tse.isAddedPath(p1B), false);
   
    // try path not recognised
    boolean pass = false;
    try
    {
      tse.isAddedPath(new TreePath("X"));
    }
    catch (IllegalArgumentException e)
    {
      pass = true;
    }
    harness.check(pass);
   
    // try null path
    pass = false;
    try
    {
      tse.isAddedPath(null);
    }
    catch (IllegalArgumentException e)
    {
      pass = true;
    }
View Full Code Here

        assertTrue(hasListener(model.getTreeSelectionListeners(),
                JTree.TreeSelectionRedirector.class));
        TreePath path = new TreePath("root");
        TreePath oldLead = new TreePath("old_lead");
        TreePath newLead = new TreePath("new_lead");
        tree.selectionRedirector.valueChanged(new TreeSelectionEvent("any_source", path, true,
                oldLead, newLead));
        assertNotNull(marker.getAuxiliary());
        TreeSelectionEvent redirectedEvent = (TreeSelectionEvent) marker.getAuxiliary();
        assertSame(tree, redirectedEvent.getSource());
        assertSame(path, redirectedEvent.getPath());
        assertTrue(redirectedEvent.isAddedPath());
        assertSame(oldLead, redirectedEvent.getOldLeadSelectionPath());
        assertSame(newLead, redirectedEvent.getNewLeadSelectionPath());
        DefaultTreeSelectionModel newModel = new DefaultTreeSelectionModel();
        tree.setSelectionModel(newModel);
        assertTrue(hasListener(newModel.getTreeSelectionListeners(),
                JTree.TreeSelectionRedirector.class));
        tree.setSelectionModel(null);
View Full Code Here

        TreePath path = new TreePath("asd");
        TreePath oldSelection = new TreePath("old");
        TreePath newSelection = new TreePath("new");
        Object source = new Object();
        boolean isNew = true;
        TreeSelectionEvent event = new TreeSelectionEvent(source, path, isNew, oldSelection,
                newSelection);
        model.fireValueChanged(event);
        assertSame(event, listener.event);
        listener.reset();
        model.fireValueChanged(null);
View Full Code Here

        assertEquals(0, ((DefaultCellEditor) editor.realEditor).getCellEditorListeners().length);
    }

    public void testValueChanged() throws Exception {
        TreePath treePath = new TreePath("root");
        editor.valueChanged(new TreeSelectionEvent(tree, treePath, true, null, treePath));
        if (isHarmony()) {
            assertEquals(treePath, editor.lastPath);
        } else {
            assertNull(editor.lastPath);
        }
View Full Code Here

TOP

Related Classes of javax.swing.event.TreeSelectionEvent

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.