Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HELP ! Scrollpanes on Panels

 
Dave Donohoe
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Kate -
I managed to fix the problem....my 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();
panel.add(bigLabel);
JScrollPane scrollPane = new JScrollPane(panel); getContentPane().add(scrollPane);
setSize(new Dimension(200, 200));
setVisible(true);
}
public static void main(String[] s)
{
new Test();
}
}
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic