I interpreted your question as asking "Can you restrict the size of a
JFrame so that it cannot be made smaller than some minimum size?"
This will be the question I am answering ;)
It's not a Mac thing, it's a Java thing. Sadly, Java still does not
handle this very well. You'll notice there is no setMinimumSize()
method in JFrame. This would solve this problem, but as yet, there is
no such API.
The best thing you can do, and it truly is a kludge, is either set the
window's resizable property to false (setResizable(false), no resizing
allowed *at all*, so no way for the window to be made smaller), or add
a component listener, and "undo" any attempts to resize the window
smaller than you want it to be. Neither solution is very professional
in my opinion, and this has been one of my pain points with Swing/AWT
for quite a while.
To "undo" resize attempts, here's a method you can call from you
window's initialization code (which I got off the Sun Java forums):
private void lockInMinSize()
{
//Ensures user cannot resize frame to be smaller than this
final int origX = 900;
final int origY = 680;
addComponentListener(new java.awt.event.ComponentAdapter()
{
public void componentResized(ComponentEvent event)
{
setSize((getWidth() < origX) ? origX : getWidth(),
(getHeight() < origY) ? origY :
getHeight());
}
});
}
This is written to be a member of your JFrame subclass, but you could
change it to pass in a reference to a JFrame and call
addComponentListner on that instance.
Rob Ross, Senior Software Engineer
E! Networks
email@hidden
---------------------------------------------------
"Beware of he who would deny you access to information, for in his
heart he dreams himself your master." -- Commissioner Pravin Lal
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden