Results 1 to 5 of 5
  1. #1
    Zazie is offline Member
    Join Date
    Jun 2014
    Posts
    13
    Rep Power
    0

    Default Show jpanel by selected node

    I have a jTree and every node referenced each jPanels.
    I don't know how to connect every node with jPanels.

    Here is my code of interest:

    public void valueChanged(TreeSelectionEvent e) {
    DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();

    if (node == null)
    return;

    if( node.equals("blue") ) {
    // link for jPanel1
    } else if( node.equals("violet") ) {
    // link for jPanel2
    }
    }

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    12,059
    Rep Power
    25

    Default Re: Show jpanel by selected node

    A DefaultMutableTreeNode is never going to be equal to a String.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,423
    Blog Entries
    7
    Rep Power
    27

    Default Re: Show jpanel by selected node

    Quote Originally Posted by DarrylBurke View Post
    A DefaultMutableTreeNode is never going to be equal to a String.

    db
    Maybe, just maybe, the op extended the DefaultMutableTreeNode class and implemented a devellish equals( ... ) method in it? :-P

    kind regards,

    Jos
    Build a wall around Donald Trump; I'll pay for it.

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    12,059
    Rep Power
    25

    Default Re: Show jpanel by selected node

    Quote Originally Posted by JosAH View Post
    Maybe, just maybe, the op extended the DefaultMutableTreeNode class and implemented a devellish equals( ... ) method in it? :-P

    kind regards,

    Jos
    Only a devilish mind would think of that :P

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  5. #5
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,423
    Blog Entries
    7
    Rep Power
    27

    Default Re: Show jpanel by selected node

    Quote Originally Posted by DarrylBurke View Post
    Only a devilish mind would think of that :P
    That's why I would never come up with something sick like that; consider me an angel.

    kindest regards,

    Jos ;-)
    Build a wall around Donald Trump; I'll pay for it.

Similar Threads

  1. Replies: 0
    Last Post: 07-26-2012, 06:21 AM
  2. Replies: 11
    Last Post: 02-08-2012, 02:43 PM
  3. How to invoke a tree as if a node selected ?
    By johny2011 in forum Advanced Java
    Replies: 5
    Last Post: 05-13-2011, 08:49 AM
  4. Get selected Node Value of a child element
    By Ms.Ranjan in forum XML
    Replies: 6
    Last Post: 10-06-2009, 09:31 PM
  5. Show Text Fields on combo Box selected value
    By smajidali26 in forum AWT / Swing
    Replies: 0
    Last Post: 11-29-2007, 09:28 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •