JScrollPane problem

I've tried to display a JPanel (bigger than screen) with a JScrollPane.

Arbore w =new Arbore(root);//this class extends JPanel

JFrame jf =new JFrame();

JScrollPane jsp =new JScrollPane();

JPanel jp =new JPanel();

jp.setLayout(new BorderLayout());

jf.getContentPane().add(jp);

jsp.getViewport().add(w);

jp.add(jsp,BorderLayout.CENTER);

jf.setExtendedState(JFrame.MAXIMIZED_BOTH);

jf.setVisible(true);

jf.setDefaultCloseOperation(jf.EXIT_ON_CLOSE);

The aplication runs, but I have no scrolls. Why?

[810 byte] By [Tibi21a] at [2007-11-27 6:51:32]
# 1
Do new JScrollPane(myPanel) instead of getViewport().add(myPanel).
kirillga at 2007-7-12 18:25:59 > top of Java-index,Desktop,Core GUI APIs...
# 2
Now I've tried:JFrame jf = new JFrame();JScrollPane jsp = new JScrollPane(myPanel);jf.setContentPane(w);Still no scrolls!
Tibi21a at 2007-7-12 18:25:59 > top of Java-index,Desktop,Core GUI APIs...
# 3
It's myPanel instead of "w" in jf.setContentPane(w)!Sorry!
Tibi21a at 2007-7-12 18:25:59 > top of Java-index,Desktop,Core GUI APIs...
# 4

Scrollbars will appear automatically when the preferred size of the component is greater than the size of the scroll pane.

I'm guessing you are using a null layout manager and haven't set the preferred size correctly.

If you need further help then you need to create a [url http://homepage1.nifty.com/algafield/sscce.html]Short, Self Contained, Compilable and Executable, Example Program[/url] (SSCCE) that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on the information provided.

Don't forget to use the [url http://forum.java.sun.com/help.jspa?sec=formatting]Code Formatting Tags[/url] so the posted code retains its original formatting.

camickra at 2007-7-12 18:25:59 > top of Java-index,Desktop,Core GUI APIs...