File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes Converting from null Layout to Layouts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Converting from null Layout to Layouts" Watch "Converting from null Layout to Layouts" New topic

Converting from null Layout to Layouts

Anurag Deepak

Joined: Jun 16, 2003
Posts: 4
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

Joined: Jul 18, 2003
Posts: 2
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

Joined: Oct 18, 2000
Posts: 4121

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.

Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Ken Blair
Ranch Hand

Joined: Jul 15, 2003
Posts: 1078
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.
I agree. Here's the link:
subject: Converting from null Layout to Layouts
It's not a secret anymore!