At 02:29 PM 10/22/2001 -0400, [EMAIL PROTECTED] wrote:
>I have a GUI consisting of three areas: > > ___ ___ > | | B | > | A |---| > | | C | > |___|___| > >* Area A contains a JTree inside a JScrollPane. > >* Area B contains a JTextField, a JButton, and 3 JRadioButtons. > >* Area C contains a JSplitPane, which in turn contains a JList within > a JScrollPane in the top pane, and a JTree within a JScrollPane in > the bottom pane. >[snip] Unfortunately I don't know exactly what's going wrong here, but I have some leads and tips: First, in GBLs, the weight constraints govern how to allocate a -change- in dimension, as opposed to total dimension. Here's an example. Suppose you have two panels in a GBL, A on the left, B on the right. A's preferred width is 400, and B's preferred width is 200. So the total layout width when packed is 600. ------------------- | A | B | ------------------- GBC for both are identical, including weightx, which is 1.0 for both. (Absolute value for weightx and weighty doesn't matter; only their ratios does.) Suppose the user resizes the frame so that the layout width changes from 600 to 800. If weightx dictated the absolute width, both A and B would become 400 pixels wide. But that's not what happens. The GBL takes the difference in width, 200, and divides that between A and B according to the weightx values. Since they're both 1, both A and B get 100 pixels, so A is 500 wide and B is 300 wide. This may explain some behavior you've seen, but not all of it. So here's another lead. My best guess, based on past experience, is that the scrollpanes and possibly C's splitpane are causing the problem. For experimentation, try removing all the scrollpanes and splitpanes (use a BorderLayout for C temporarily) and seeing what that does to the behavior. Assuming B has some simple layout, its preferred size should be easy enought to understand. However, the rules for the preferred size of JScrollPanes and JSplitPanes are somewhat more complicated. JScrollPanes in particular follow different rules depending on whether the component in their viewport implements the Scrollable interface. Check out the Scrollable documentation for the methods it defines, and their effect on a JScrollPane's preferred size. (Both JList and JTree implement Scrollable, by the way.) Ultimately what you might have to do is subclass one or more of the JLists or JTrees, and override one or more of the Scrollable methods to return a value that causes the behavior you need. You may even have to override getPreferredSize() in those components. More experimentation: put a JButton in a separate JFrame, or register a keyboard action on the current frame, that prints out the preferred and current sizes of the various components in the interface. (Don't put this code in a resize listener; the timing will be wrong.) _______________________________________________ Swing mailing list [EMAIL PROTECTED] http://eos.dk/mailman/listinfo/swing
