Skip to main content

[Appframework]: how to keep super from pack()'ing initially?

No replies
Joined: 2003-06-11
Points: 0

the concrete frame in question - surprise, surprise :-) - it the mainframe of the SwingXSet: the layout still isn't clean enough to survive a pack. And don't intend to go for the real reason just now, still hoping the _real_ solution will drop out of the sky (which occasionally happens with layout probs). The original version in SwingSet3 side-stepped any problems by ...horror: freely setting preferredSizes and null layout.

This is a problem only in the very first run of the app, later the size/location is restored from persisted session state. A quick fix was to manually size the frame always - which wasn't a solution at all because it short-cuts the restored values. Now I came up with something looking extremely dirty: override configureWindow, pack, set a reasonable enough initial size and validate:

<br />
    @Override<br />
    protected void configureWindow(Window root) {<br />
        super.configureWindow(root);<br />
        if (root == getMainFrame()) {<br />
            // PENDING JW<br />
            // brute force: prevent super from pack()'ing the mainframe<br />
            // initially - actually it's a problem of our overall<br />
            // layout, packing giving horrible results ...<br />
            // we have to do it here (instead of in show as I assumed)<br />
            // because super's injecting properties will invalidate<br />
            root.pack();<br />
            root.setBounds(0, 0, 1024, 748);<br />
            root.validate();<br />
        }<br />

Probably overlooking something obvious - any ideas, what?