 |
 |
Minimum window sizes in Java?
|
 |
|
 |
|
Professional Poster
Join Date: Oct 2001
Status:
Offline
|
|
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
|
|
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
|
|
|
|
|
|
| |
|
|
|
 |
|
 |
|
Professional Poster
Join Date: Oct 2001
Status:
Offline
|
|
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
|
|
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.
|
|
|
| |
|
|
|
 |
|
 |
|
Professional Poster
Join Date: Oct 2001
Status:
Offline
|
|
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
|
|
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
|
|
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
|
|
|
| |
|
|
|
 |
|
 |
|
Professional Poster
Join Date: Oct 2001
Status:
Offline
|
|
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.
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|