Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem in Using JScrollPane  RSS feed

 
Amirr Rafique
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all

I m trying to use JScrollPane. The scenario is I got a JPanel which in having a label with image and that panel is added in JScrollPane. If I use defualt Layout of JPanel; ScrollPane works fine but if we set Layout to null then it do not works . Is there a way to use scroll bar with a panel having layout set to null ??

Thanks
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When the layout is null, the JPanel has no idea what size it should be, since it's not looking at its contents (that's the layout manager's job.) Use JPanel.setPreferredSize() to tell the JPanel what size it wants to be.
 
Amirr Rafique
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks dude, It works
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!