aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes How to create a flexible window? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to create a flexible window?" Watch "How to create a flexible window?" New topic
Author

How to create a flexible window?

Lars Tode
Ranch Hand

Joined: Feb 07, 2002
Posts: 45
Hi,
i have a window (jframe) with some components. Theres a JTextArea in a JScrollPane, some JButtons, a JMenuBar and some JLabels.
My problem is that when i show the window on other os than mine, the proportion of each component changed. Because i've worked width fixed
sizes for each component, i get the problem with the proportion of the components.
Now i want to create component which have relative sizes to the window, example jscrollpane.setPreferredSite(new Dimension(windowWidth - 10, windowHeight - 50)).
But i'm not sure that it is the right way. I found in the API the method getInsets() for JFrame
but whenn i used it, i get for ((Insets)myWindow.getInsets()).left 0.
Is there a possibility to get the Dimensions of the JFrame including the border, title an menu?
Greetx
Lars
Chantal Ackermann
Ranch Hand

Joined: Sep 28, 2000
Posts: 508
you should use a LayoutManager and define relations between the sizes of your components. For example: JScrollpane should fill the lower half of the frame, if the frame gets resized the scrollpane should grow and shrink the other components shouldn't.
You can specify the empty space between the components using the layout manager.
My recommendation use GridBagLayout.
See the Swing Tutorial on Layout Managers.
Lars Tode
Ranch Hand

Joined: Feb 07, 2002
Posts: 45
Hi,
I also use the GridBagLayout but I still have problems with it.
For example when I use a JEditorPane in a JScrollPane and I don't specify the size of the JScrollPane (with setPreferredSize, setMaximumSize, setMinimumSize) it collapses.
Do you know a possibility?
Regards
Lars
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to create a flexible window?