I have DocumentWindow
, and it is resizable.
But wen I set
setResizeLimits(600, 400, getScreenBounds().getWidth(), getScreenBounds().getHeight());
I cannot resize it anymore, but maximise only.
Why?
I have DocumentWindow
, and it is resizable.
But wen I set
setResizeLimits(600, 400, getScreenBounds().getWidth(), getScreenBounds().getHeight());
I cannot resize it anymore, but maximise only.
Why?
When are you calling that? The window probably has a size of 0x0 when you’re calling getWidth and getHeight so you’re setting the max size to 0x0
getScreenBounds()
probably doesn’t work the way you expect. The docs say:
Returns the bounds of this component, relative to the screen’s top-left.
The code you posted will set the maximum width/height to the component’s current width/height. I’d recommend picking a large number and using that, rather than explicitly trying to use the screen size.
Using the screen size may not be a good idea - for example, if the user has multiple displays of different sizes, and opens the app on a smaller display, they would still expect to be able to resize the window to the size of a larger display.