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
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.
Joined: Feb 07, 2002
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