> I have a JScrollPane and a JList in a JPanel. Using the default layout
> manager nothing happens. The size of the JScrollPane
> does not change.
You must be using the layout manager incorrectly, why not post a small
working Java program that illustrates your problem, then people can
point out how to fix it.
> Now I removed the layout manager. I manually adjust the
> size of the JScrollPane when ever the user clicks on it.
Removing the layout manager seems rather foolish to me.
> I would be glad if you could mention me how to do it using the layout
> manager. An example code will be perfect if you have time and will to
> send one.
I'd use BorderLayout (the default for content panes) and
add (scroller, BorderLayout.CENTER);
http://java.sun.com/docs/books/tutorial/uiswing/layout/border.html
asd - 07 Mar 2007 01:28 GMT
>> I have a JScrollPane and a JList in a JPanel. Using the default layout
>> manager nothing happens. The size of the JScrollPane
[quoted text clipped - 16 lines]
> add (scroller, BorderLayout.CENTER);
> http://java.sun.com/docs/books/tutorial/uiswing/layout/border.html
I compiled following code as a Bean. When the size of the panel Changes
the size of the JScrollPane stays the same. I would like size of
ScrollPane to always fit the size of the Panel.
I hope I made myself clear this time.
public class TestFoolness extends JPanel{
JList lst;
JScrollPane pn;
/** Creates a new instance of TestFoolness */
public TestFoolness() {
super(); // gets default layout manager
lst = new JList(new String[] {"asd", "qvy", "zxc"});
pn = new JScrollPane(lst);
add(pn);
}
}
asd - 07 Mar 2007 04:44 GMT
>>> I have a JScrollPane and a JList in a JPanel. Using the default layout
>>> manager nothing happens. The size of the JScrollPane
[quoted text clipped - 38 lines]
>
> }
Thank you so much for your help Ian. After trying several different
things. I figured that out it works with BorderLayout. I had been trying
to do it with default LayoutManager.
I really appreciate your help.