• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Converting from null Layout to Layouts

 
Anurag Deepak
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have made a project using setLayout(null) and added the components using setBounds.
Now the requirement is that we have to use Layouts, so that the program runs in various resolutions (800x600) and (1024x768), which is not possible using hard bound values.
How can I do this ?
When I use scrollPane to add a table,and add it without using setSize, then it takes the whole window.
Is there any other way to write a GUI SWING application which is independent of the screen resolution?
 
Johanna Sousa
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.
I'm a little curious about why you opted not to use a layout manager if you don't mind me asking.
- Johanna
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For general information on how to use different layout managers, check out the Swing Tutorial.

As for the table taking up the whole frame... use the setPreferredScrollableViewportSize( Dimension ) method of JTable to set the size you want the scrollpane to be.
 
Ken Blair
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I feel your pain, I've read the Swing Tutorial and I still don't have a clue how to design a UI that looks good, even a simple form, using the layout managers.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic