Question

Is there any way in Java to enforce a minimum window size?

The last article I can find is from 1999, and has some complicated code to mimic the behaviour... http://www.javaworld.com/javaworld/javaqa/1999-10/03-qa-window.html

Surely there is a simple method that can be used?

Was it helpful?

Solution

I usually set the minimum size of a window by setting the minimum sizes of the JComponents inside of the window.

jcomponent.setMinimumSize(Dimension d);

That line of code will limit a component's minimum size.

You can also call setMinimumSize() on the JFrame directly to achieve a similar effect.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top