swing, JScrollPane

J

Jelena Marin

Hi guys, one more question. Suppose I put three panels in JScrollPane;
when I scroll to the right only two are moving and the third one is
visible and doesn't change, and when I scroll to the bottom, again: two are
moving, and third one is visible and doesn't change... can I achieve this?
Tnx.
 
F

Fred Kleinschmidt

Jelena Marin said:
Hi guys, one more question. Suppose I put three panels in JScrollPane;
when I scroll to the right only two are moving and the third one is
visible and doesn't change, and when I scroll to the bottom, again: two
are
moving, and third one is visible and doesn't change... can I achieve this?
Tnx.

A JScrollPane should have one and only one child.
In your case, the child should be a JPanel that has three JPanel children.
 
T

Thomas Hawtin

Fred said:
A JScrollPane should have one and only one child.
In your case, the child should be a JPanel that has three JPanel children.

Technically, a JScrollPane will have multiple children - scroll bars,
view-port and anything configured by Scrollable contents. But yes,
generally add one component through constructor (or setViewportView).
Use a panel to layout components within the scrollable area.

Tom Hawtin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top