Results 1 to 6 of 6

Thread: JTree class of java

  1. #1
    Join Date
    Dec 2009
    Posts
    32

    JTree class of java

    Hello friend,

    I am new to the field of java programming language. The 'JTree class' of java seems very complicated to understand. According to my knowledge JTree class is oftenly used class of java. I have referred many advanced java books for JTree class, but nothing was helpful. If you posses sound knowledge about the JTree class of java, then please let me know that. I would greatly appreciate your any help.

  2. #2
    Join Date
    Apr 2008
    Posts
    1,948

    Re: JTree class of java

    A specific node in a Jtree class can be identified either by a TreePath (an object that encapsulates a node and all of its ancestors), or by its display row, where each row in the display area displays one node. An expanded node is a non-leaf node (as identified by TreeModel.isLeaf(node) returning false) that will displays its children when all its ancestors are expanded. A collapsed node is one which hides them. A hidden node is one which is under a collapsed ancestor.

  3. #3
    Join Date
    May 2008
    Posts
    2,012

    Re: JTree class of java

    Please refer following example of JTree class of java:
    Code:
    import javax.swing.JTree;
    import javax.swing.JFrame;
    import javax.swing.JScrollPane;
    
    public class JTreeDemo
     {
      public static void main(String args[]) {
        JFrame fU = new JFrame("JTree Sample");
        fU.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        Container content = fU.getContentPane();
        JTree tree = new JTree();
        JScrollPane scrollPane2 = new JScrollPane(tree);
        content.add(scrollPane2, BorderLayout.CENTER);
        fU.setSize(400, 200);
        fU.setVisible(true);
      }
    }

  4. #4
    Join Date
    Apr 2008
    Posts
    2,005

    Re: JTree class of java

    Hello friend,

    A JTree class comprises four nested class, see below:
    • JTree.TreeSelectionRedirector: This class is used for handling creation of TreeSelectionEvent
    • JTree.AccessibleJTree: This class is used for implementation of access
    • Tree.TreeModelHandler: This class is used for the updation of expandedState
    • JTree.EmptySelectionModel: This class is has same working as TreeSelectionModel

  5. #5
    Join Date
    May 2008
    Posts
    2,297

    Re: JTree class of java

    I have one program of java, which will depict you the use of JTree class of java. Please review following example :
    Code:
    import javax.swing.JTree;
    
    public class TreeLinesDemo {
      public static void main(String args[]) {
        JFrame frameP = new JFrame("Tree Lines");
        frameP.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    
        Container content = frameP.getContentPane();
        Box box = Box.createHorizontalBox();
    
        JTree tree01 = new JTree();
        tree01.putClientProperty("JTree.lineStyle", "Angled");
        JScrollPane scrollPane1 = new JScrollPane(tree01);
        tree01.setAutoscrolls(true);
    
        JTree tree02 = new JTree();
        JScrollPane scrollPane2 = new JScrollPane(tree02);
    
        box.add(scrollPane1, BorderLayout.WEST);
        box.add(scrollPane2, BorderLayout.EAST);
    
        frameP.getContentPane().add(box, BorderLayout.CENTER);
        frameP.setSize(200, 240);
        frameP.setVisible(true);
      }
    }

  6. #6
    Join Date
    Oct 2005
    Posts
    2,393

    Re: JTree class of java

    Hi,

    we can use various fields with JTree class of java, following are some of them:
    1. ROOT_VISIBLE_PROPERTY Field
    2. invokesStopCellEditing Field
    3. INVOKES_STOP_CELL_EDITING_PROPERTY Field
    4. CELL_EDITOR_PROPERTY Field
    5. ANCHOR_SELECTION_PATH_PROPERTY Field

Similar Threads

  1. Java program to add selection listener to JTree
    By Juany in forum Software Development
    Replies: 4
    Last Post: 23-01-2010, 04:25 PM
  2. Java program to remove JTree default icons?
    By Baazigar in forum Software Development
    Replies: 4
    Last Post: 22-01-2010, 07:35 PM
  3. How to remove a node from JTree in java program?
    By kamina23 in forum Software Development
    Replies: 4
    Last Post: 22-01-2010, 05:41 PM
  4. Java program to expand or collapse all JTree nodes.
    By KALIDA in forum Software Development
    Replies: 4
    Last Post: 22-01-2010, 05:04 PM
  5. Replies: 5
    Last Post: 22-01-2010, 04:17 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,028,664.27032 seconds with 16 queries