all individual panels are not shown inside root panel

Posted by Suresh Kumar on Stack Overflow See other posts from Stack Overflow or by Suresh Kumar
Published on 2012-06-19T14:43:11Z Indexed on 2012/06/19 15:16 UTC
Read the original article Hit count: 388

Filed under:
|
|
|
|

Respected sir/madam,

I want to add multiple jpanels to jpanel.So i added a root panel to jscrollpane.and then added all individual jpanels to this root panel.I made jscrollpane's scrolling policy as needed.i.e HORIZONTAL_SCROLLBAR_AS_NEEDED,VERTICAL_SCROLLBAR_AS_NEEDED. But the problem is all individual panels are not shown inside root panel.

Code:

JScrollPane scPanel=new JScrollPane();

JPanel rootPanel=new JPanel();
rootPanel.setLayout(new FlowLayout());

JPanel indPanel = new JPanel();
rootPanel.add(indPanel);

JPanel indPanel2 = new JPanel();
rootPanel.add(indPanel2);

//.....like this added indPanals to rootPanel.
scPanel.setViewPortView(rootPanel);
//scPanel.setHorizontalScrollPolicy(HORIZONTAL_SCROLLBAR_AS_NEEDED);

And one more thing is, as i scroll the scrollbar the panels are going out of jscrollpane area. I am not able to see all individual panels, Please suggest me.

© Stack Overflow or respective owner

Related posts about java

Related posts about swing