The moose likes Swing / AWT / SWT and the fly likes HELP ! Scrollpanes on Panels Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "HELP ! Scrollpanes on Panels" Watch "HELP ! Scrollpanes on Panels" New topic

HELP ! Scrollpanes on Panels

Dave Donohoe
Ranch Hand

Joined: May 16, 2000
Posts: 73
Hi all - hope you can help...
I have a JPanel & I have a JScrollPane on it.....
the panel & the components on it are seen, as are the scrollbars but it wont scroll. I know there are components hidded that it should scroll to, but it just wont scroll....
Any ideas?
kate damond
Ranch Hand

Joined: Apr 17, 2001
Posts: 77
I have a seemingly similar problem - I have a JScrollPane with a JTable in it - the table is longer and wider than the pane, when the application is running, and although both scrollbars look good, only the vertical bar allows scrolling - the horizontal one doesn't.
Any ideas ?
Thanks, Kate
Dave Donohoe
Ranch Hand

Joined: May 16, 2000
Posts: 73
Hi Kate -
I managed to fix the code was OK, the problem I was having was that the order in which I created & added the ScrollPane & the Panel I wanted on it was a bit off....its very weird....but this code (which I found elsewhere on JavaRanch) shows a correct order for the components....I dont know if it will make a difference in your app, but it did help me......
import java.awt.*;
import javax.swing.*;
public class Test extends JFrame
public Test()
JLabel bigLabel = new JLabel("Really Big Label"); bigLabel.setFont(bigLabel.getFont().deriveFont(200.0F));
JPanel panel = new JPanel();
JScrollPane scrollPane = new JScrollPane(panel); getContentPane().add(scrollPane);
setSize(new Dimension(200, 200));
public static void main(String[] s)
new Test();
I agree. Here's the link:
subject: HELP ! Scrollpanes on Panels
It's not a secret anymore!