Reputation: 5207
I am using this code to add a scroll panel in my JFrame
JScrollPane pane = new JScrollPane(getContentPane(),
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
this.setContentPane(pane);
I can view the scroll-bar but it is not scrollable even after resizing the window.
Upvotes: 3
Views: 923
Reputation:
use this code it worked for me
container.setSize(1800, 1500);
container.setVisible(true);
container.setPreferredSize(new Dimension(900, 900));
JScrollPane scrollPane = new JScrollPane(container);
scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
add(scrollPane);
Upvotes: 2
Reputation: 5207
Yupii!!!!!! Got the solution of my problem. I just need to add
setPreferredSize(new Dimension(900, 900));
to my contentpane. Thanks For every one.
Upvotes: 2