Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Minimum window sizes in Java?

Minimum window sizes in Java?
Thread Tools
Professional Poster
Join Date: Oct 2001
Status: Offline
Reply With Quote
Jul 21, 2004, 10:51 PM
 
How do I make it so that the user can't resize the window to a certain point? And if I can't then how do I just make it so they can't drag the resize corner at all?
     
Professional Poster
Join Date: Oct 2001
Status: Offline
Reply With Quote
Jul 22, 2004, 12:08 AM
 
Edit: Woops! Spoke too soon. Doesn't really work... while dragging it I can see it *struggling* to resize but it doesn't... I don't think there is a way to do this simple thing at all in java...

I thought this would work but I tried it and it didn't.
http://www.javaworld.com/javaworld/j...qa-window.html
(Last edited by itistoday; Jul 22, 2004 at 12:41 PM. )
     
Dedicated MacNNer
Join Date: Oct 2003
Location: Round Rock, TX
Status: Offline
Reply With Quote
Jul 23, 2004, 01:02 PM
 
dlg.setResizable(false) removes the resize handle.

Plug: for Java layout assistance, check out http://www.computersinmotion.com
     
Professional Poster
Join Date: Oct 2001
Status: Offline
Reply With Quote
Jul 25, 2004, 12:58 AM
 
Just for fun I decided to create at least some sort of solution—be it lackluster or not. So I made a subclass of javax.swing.Frame that did the following:

It implemented a Timer that would be turned on each time the window was resized, and would automatically turn off after 10 seconds. This Timer checks the size of the window every second, and if it's too small, then it resizes it.

So what happens is the user resizes the window and makes it all ugly, and a split-second later it snaps back to the way it should be

This was my first actual Java project thus far and I must say I'm quite pleased
     
Forum Regular
Join Date: Nov 2002
Location: PVD/MSP
Status: Offline
Reply With Quote
Jul 25, 2004, 11:36 PM
 
Check out java.awt.event.ComponentListener. It has a method that informs you when the component is resized. Each time that method gets called check to see if it is smaller than the minimum size and if so, resize it to the minimum size.
dearinter.net consensus life coaching.
     
Professional Poster
Join Date: Oct 2001
Status: Offline
Reply With Quote
Jul 25, 2004, 11:57 PM
 
Originally posted by off/lang:
Check out java.awt.event.ComponentListener. It has a method that informs you when the component is resized. Each time that method gets called check to see if it is smaller than the minimum size and if so, resize it to the minimum size.
That's actually exactly what I did (had you clicked the link in the 2nd post you've seen that exact strategy). I combined that with the timer, and now it works somewhat better... albiet strangly. Simply resizing it everytime it gets too small (as suggested in the link) doesn't work at all.
     
Professional Poster
Join Date: Oct 2001
Status: Offline
Reply With Quote
Jul 26, 2004, 01:02 AM
 
Discovery: While fiddling with this problem further, I discovered that the "Metal" Look and Feel actually handles resizing as suggested in the first link well. It is all the other Look and Feels like the OS X feel and the rest that resize poorly. I'm not sure if this is a Mac-only problem but investigations are underway I assure you

In the mean time, if you are writing Java apps and would like to give your windows a minimum size, I suggest using the method described in the link in the second post, and using the "Metal" (AKA Cross-platform) look and feel.

Edit: There seems to be two versions of 'Metal' depending on something that I don't know... One has the Apple title bar, and the other has the 'Metal' title bar that is purple. The one that resizes well is the one with the purple title bar.
(Last edited by itistoday; Jul 26, 2004 at 01:32 AM. )
     
Forum Regular
Join Date: Nov 2002
Location: PVD/MSP
Status: Offline
Reply With Quote
Jul 26, 2004, 08:13 AM
 
I think Apple's live resizing property has a lot to do with the fact that it seems to work poorly. The property is com.apple.mrj.application.live-resize
dearinter.net consensus life coaching.
     
Professional Poster
Join Date: Oct 2001
Status: Offline
Reply With Quote
Jul 26, 2004, 11:00 AM
 
Originally posted by off/lang:
I think Apple's live resizing property has a lot to do with the fact that it seems to work poorly. The property is com.apple.mrj.application.live-resize
How do I turn that off? I haven't really used properties much. I tried 'java -Dcom.apple.mrj.application.live-resize=false -jar Myapp.jar' but that didn't work.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 01:04 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2