Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Minimum size for JFrame  RSS feed

 
Brian Kelly
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is driving me nuts.

Is it possible to specify the minimum size of a resizeable JFrame (in 1.4) ???

I can do this:

frame.addComponentListener(new java.awt.event.ComponentAdapter() {
public void componentResized(ComponentEvent e) {
JFrame tmp = (JFrame)e.getSource();
int w = tmp.getWidth();
int h = tmp.getHeight();
if (tmp.getWidth()<600) w = 600;
if (tmp.getHeight()<400) h = 400;
tmp.setSize(w, h);
}
});

But this still lets me reduce the JFrame size to 0, and then when I release, it'll spring back to the this minimum.

What I want is it to stop reducing the JFrame at some point before size 0...

Is that possible?

Cheers!
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this seems to work OK in 1.5 (can't test it in 1.4 till later)


if preferredSize for JFrame is a 1.5 thing, you may need to modify slightly

 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the code with the addition of the JPanel as the contentPane works OK in 1.4.0_01

the first lot of code errors with "cannot resolve...." for the setMin/Pref/Size(..)
 
Brian Kelly
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Great! Thanks a lot...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!