Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Adding Scrollbar to JPanel...

843806Mar 6 2008 — edited Mar 13 2008
Hi i need to add scrollbar to JPanel. I added a JPanel to JScrollpane. Then i added the JScrollpane to JFrame but only the JScrollPane gets displayed and not the JPanel.

final BarChartDisp bcd = new BarChartDisp(ptcor1,ptcor2,max, "Event Specication - "+eventsCount+":"+event);
java.awt.EventQueue.invokeLater(new Runnable() {

public void run() {
bcd.getContentPane().setLayout(new BorderLayout());
JScrollPane js = new JScrollPane();
js.setLayout(new ScrollPaneLayout());
JPanel p = bcd.fillItems();
js.add(p);
js.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
bcd.getContentPane().add(js);
bcd.setVisible(true);

}

here BarChartDisp extends JFrame. bcd.fillItems() returns an object of class BarChart which extends JPanel. Pl help..

Thanks!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 10 2008
Added on Mar 6 2008
6 comments
363 views