• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

JScrollPane problem

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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,

Eoin.
 
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
That's my roommate. He's kinda weird, but he always pays his half of the rent. And he gave me this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic