insert JTree and JTable into JInternalFrame

Hello there,

I want to have a JTree and JTabbedpane in a JInternalFrame.the JTree will get populated from the database so will the JTabbedpane.the JTabbedPane will have tables which will show data from the database when a tree node is clicked.i want to know how should i start implementing this.or are there any code.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Manikandan ThiagarajanSenior consultantCommented:
Mayank SAssociate Director - Product EngineeringCommented:
For a start, make your own TreeModel and use it to populate it from the database:

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
zolfAuthor Commented:

i have a problem with JScrollPane,that is when i expand the tree nodes then the scroll pane gets activated,but when i move the JInternalFrame the scrollpane disappears.i have added a JScrollPane to a JPanel and the JPanel is put in a JInternalFrame

JScrollPane scrollPane = new JScrollPane();
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Mayank SAssociate Director - Product EngineeringCommented:
Try JScrollPane scrollPane = new JScrollPane ( tree ) ;

Don't add the tree to the container directly if you are doing so somewhere and also don't set its size, etc.
zolfAuthor Commented:

ok i solved that problem by using setPreferredSize().

i want to know is it possible to drag the left panel directly where the tree is.instead of using the scrollbar.
Mayank SAssociate Director - Product EngineeringCommented:
Meaning, drag and drop it?
zolfAuthor Commented:

no i want to add a JSplitPane so i can increase the size of the panel where the Jtree is.
zolfAuthor Commented:
is it possible not to have a rightComponent in a splitpane because when i done put the right component i cannot resize the panel. splitPane.setRightComponent(htmlView);

this is the code:

treePanel = new DynamicTree(); //this is a JPanel
            Container c = this.getContentPane();
            //c.add( treePanel, BorderLayout.WEST );
        JScrollPane htmlView = new JScrollPane();
            //Add the scroll panes to a split pane.
        JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT );
        splitPane.setLeftComponent( treePanel);

            Dimension minimumSize = new Dimension(50, 50);
        htmlView.setMinimumSize(new Dimension(0, 0));
        //treeView.setPreferredSize(new Dimension(100, 100));
        splitPane.setPreferredSize(new Dimension(500, 300));
        c.add( splitPane, BorderLayout.WEST );            
            setLocation((screen.width - 747)/2,((screen.height-450)/2)-45);
            setFrameIcon(new ImageIcon("images/customer.png"));
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.