• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 920
  • Last Modified:

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.

cheers
zolf
0
zolf
Asked:
zolf
  • 4
  • 3
1 Solution
 
Manikandan ThiagarajanSenior consultantCommented:
0
 
Mayank SAssociate Director - Product EngineeringCommented:
For a start, make your own TreeModel and use it to populate it from the database:

http://java.sun.com/docs/books/tutorial/uiswing/components/tree.html
0
 
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();
      scrollPane.getViewport().add(tree);
        add(scrollPane);
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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.
0
 
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.
0
 
Mayank SAssociate Director - Product EngineeringCommented:
Meaning, drag and drop it?
0
 
zolfAuthor Commented:

no i want to add a JSplitPane so i can increase the size of the panel where the Jtree is.
0
 
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
            
            populateTree(treePanel);
            
            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);
        splitPane.setRightComponent(htmlView);


            Dimension minimumSize = new Dimension(50, 50);
        htmlView.setMinimumSize(new Dimension(0, 0));
        treePanel.setMinimumSize(minimumSize);
        splitPane.setDividerLocation(200);
       
        //treeView.setPreferredSize(new Dimension(100, 100));
        splitPane.setPreferredSize(new Dimension(500, 300));
       
            //getContentPane().add(splitPane);
        c.add( splitPane, BorderLayout.WEST );            
            
            setSize(747,450);
            setLocation((screen.width - 747)/2,((screen.height-450)/2)-45);
            setFrameIcon(new ImageIcon("images/customer.png"));
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now