Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JFrame cannot be resized narrower than the width required to accommodate its title #351

Closed
johnmgithub opened this issue Jul 8, 2021 · 6 comments
Milestone

Comments

@johnmgithub
Copy link

A width-resizeable JFrame cannot be resized narrower than the width required to accommodate its title (flatlaf-1.3).

@DevCharly
Copy link
Collaborator

Hmm, I can make the FlatLaf Demo very small (on Windows 10):

image

Can you give us more details?
Screenshot?

@johnmgithub
Copy link
Author

I was just trying it out, here is the narrowest one of my components gets with FlatLAF:

image

Here is the narrowest it gets when using Nimbus as the underlying LAF:

image

I'm speculating the title is the problem since the width happens to be just right to accommodate the title. The panel within the frame uses TableLayout but the frame uses BorderLayout with the panel added at CENTRE.

@DevCharly
Copy link
Collaborator

I see!

So you have some code in your app that prevents resizing window smaller than preferred (or minimum) size of components, right?

And because the window title in FlatLaf is also implemented in Swing, and has some preferred/minimum size, it prevents smaller window width.

@johnmgithub
Copy link
Author

Sort of. getMinimumSize is overridden for the panel within the frame based on component sizes in the panel, but not for the frame itself. The minimum for the frame is set based on using frame.pack(). I think the problem is that frame.pack() is adjusting the frame's size to accommodate its own title rather than to accommodate the components within it. I'm not sure that really respects the contract for pack(), since I wouldn't have said a frame's title constitutes a subcomponent:

    /**
     * Causes this Window to be sized to fit the preferred size
     * and layouts of its subcomponents. The resulting width and
     * height of the window are automatically enlarged if either
     * of dimensions is less than the minimum size as specified
     * by the previous call to the {@code setMinimumSize} method.
     * <p>
     * If the window and/or its owner are not displayable yet,
     * both of them are made displayable before calculating
     * the preferred size. The Window is validated after its
     * size is being calculated.
     *
     * @see Component#isDisplayable
     * @see #setMinimumSize
     */
    public void pack() 

DevCharly added a commit that referenced this issue Jul 8, 2021
…en calculating preferred/minimum width of window (issue #351)
@DevCharly
Copy link
Collaborator

Should be fixed in main branch.
Please try latest snapshot: https://github.com/JFormDesigner/FlatLaf#snapshots

@DevCharly DevCharly added this to the 1.4 milestone Jul 8, 2021
@johnmgithub
Copy link
Author

That fixed it, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants