Results 1 to 3 of 3
  1. #1
    MrNice is offline Member
    Join Date
    Jan 2014
    Posts
    16
    Rep Power
    0

    Default jtree seperate class

    Hi again, i am trying to get around with swing. The problem is this:

    Main file
    declarations{JTree tree, DT drzewo}
    actionlisteners
    gui

    Seperate files
    ActionsTake Listeners
    List and Jtree

    My problem is that how to do it with JTree
    PHP Code:
    public class DirectoryTree extends JTree{
    		public JTree tree;
    		public DefaultMutableTreeNode root;		
    		public DirectoryTree(JTree tree, DefaultMutableTreeNode root){
    			this.tree=tree;
    			this.root=root;		
    			tree =new JTree(root);
    			System.out.println(root);
    			
    		}
    anything else
    }

    DefaultMutableTreeNode abc = new DefaultMutableTreeNode("Sry Not Working");
    drzewo =new DirectoryTree(tree,abc);

    And in run JTree tree is returning null component???? wtf is going on Can Jtree be creted in other subclass and be return or how to do it that Myclass is pointing to Jtree tree.. Cannot get to it....

  2. #2
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    1,991
    Rep Power
    8

    Default Re: jtree seperate class

    You are extending JTree and you also have one as a field. I am pretty sure that is not necessary. If you extend JTree then your DirectoryTree *is* a JTree.
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2 2013

  3. #3
    MrNice is offline Member
    Join Date
    Jan 2014
    Posts
    16
    Rep Power
    0

    Default Re: jtree seperate class

    Hey it worked :*

    Before that i was not extending and it was more worst..
    +

Similar Threads

  1. Running Modules From A Seperate Class
    By jo15765 in forum New To Java
    Replies: 8
    Last Post: 08-13-2013, 04:16 PM
  2. Removing panels from a seperate class
    By RayDunster in forum New To Java
    Replies: 2
    Last Post: 01-19-2012, 07:38 PM
  3. Help displaying an array from a seperate class
    By aeon1613 in forum New To Java
    Replies: 2
    Last Post: 01-16-2011, 08:15 AM
  4. Keyboard Input In A Seperate Class?
    By FatalSylence in forum New To Java
    Replies: 6
    Last Post: 10-12-2010, 05:29 AM
  5. Manipulating components of a seperate GUI Class
    By ribbs2521 in forum New To Java
    Replies: 1
    Last Post: 10-20-2009, 10:53 PM

Posting Permissions

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