Bug 25 : prevent the editor window from being resized too small
Last modified: 2010-02-05 12:09



Assigned To:

Attachment Type Created Size Actions

Description:   Opened: 2005-05-12 20:14
java seems inconsistent about handling this properly via setMaximumSize()
and whatnot, but might be worth a try.
Additional Comment #1 From Lonnen 2010-02-05 08:03
There doesn't appear to be good way to maintain a minimum size in a java
window. Comp.lang.java.gui (Q5.9) has some insights, but it seems like the
only accepted way is to listen in to window resize events and if the window
would be set too small trigger a second resize to a set minimum. This
causes the window to appear to jump around though, and it may be better to
leave it the way it is.

If this is a desirable solution, however, let me know and I will try to
write it up.
Additional Comment #2 From fry 2010-02-05 11:16
Thanks for looking. The reason for this bug was that people sometimes made
the window too small, which makes the console and other parts disappear,
which can then cause confusion about where they've gone. For instance,
you'd have a student in a course who accidentally got rid of it, and a
teacher confused about where the console etc had gone in the app.

Is it possible to only do the resize after the user has let go with the
mouse? In that case, it might be OK to have it jump, because we should
probably have it re-expand to the point that at least all the necessary
components (editor, console, etc) are visible, so that people aren't
getting windows into a weird state.
Additional Comment #3 From Lonnen 2010-02-05 11:24
It was a quick writeup. The values need to be changed, and it doesn't look
great, but if you want to use it you have a solution.
Added at line 280 in Editor.java, right before the end of the Editor class:

// If the window is resized too small this will resize it again to the
// adapted from comments here:
// Possible fix for: http://dev.processing.org/bugs/show_bug.cgi?id=25
final int minX = 400; //kind of arbitrary
final int minY = 600;
addComponentListener(new java.awt.event.ComponentAdapter() {
public void componentResized(ComponentEvent event){
setSize((getWidth() < minX) ? minX : getWidth(),
(getHeight() < minY) ? minY : getHeight());
Additional Comment #4 From fry 2010-02-05 12:09
cool, thanks. i've integrated that and added preferences for the default
settings after doing a quick mac/windows/linux test to figure out good

the code is now in the repository, but you'll need to remove your work
folder and rebuild after updating, because of the preferences.txt changes.

thanks again for your help!