This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes JScrollPane problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JScrollPane problem" Watch "JScrollPane problem" New topic

JScrollPane problem

Eoin Mac Aoidh
Ranch Hand

Joined: May 19, 2005
Posts: 48
Hi all,
I am having a bit of trouble making a window that will provide scroll capabilities and contain a JPanel.
My code works fine for creating a window to provide scroll capabilities for a JLabel that is too big for the window (Just not for a panel, and I cant figure out why!!!)

Heres what Ive got:

Is it just not possible to do this for a panel?
I would be delighted with any pointers.
Many thanks,

Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
ScrollPanes need to know the preferredSize of their child/view components. If the child/view component does not have any children then its layout manager, null here, will not have a preferredSize computed to answer the parent containers call for it as part of the layout process. So you have to provide this information for the component so the parent/scrollPane can get it in when it asks for it.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: JScrollPane problem
Similar Threads
how to add a scrollpane...
Wanted: example mouse coordinates->world coordinates
JFrame won't repaint...
RepaintManager and painting JPanel question
Need Guru's help!!