• Post Reply Bookmark Topic Watch Topic
  • New Topic

Adding scroll bars to JFrame when components are going out of screen  RSS feed

 
chets patel
Ranch Hand
Posts: 77
Eclipse IDE Redhat Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all
I want to add scroll bars to the JFrame when my components are going out of screen. I dont want to use any layouts. I have read old posts but all are suggesting to use layout. Any solution without layout.
Please help.
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, you could write code that determines the preferredSize of a container based on its contents. Oh, wait, that's (part of) what a layout manager does and what you don't want to use.

Nope, no solution.
 
Stephan van Hulst
Saloon Keeper
Posts: 7817
142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you will still have to use layout managers. In order to solve your problem, just use a panel with the components laid out like you want them to, and then add that panel to a JScrollPane. You can add this scroll pane to your frame and presto.
 
chets patel
Ranch Hand
Posts: 77
Eclipse IDE Redhat Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ohh that means I have to change my design...
Ok...will do the same.
Thanks Stephan and Darryl
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!