Skip to main content

How to resize only one dimension of a JFrame at run-time?

2 replies [Last post]
ZioCrick
Offline
Joined: 2013-06-04
Points: 0

Hi everyone.
I am very newbie about Java (and Linux environment).
I use Java 1.7.0_21 OpenJDK 64bit with NetBeans IDE 7.3 on Kubuntu 12.10.

I have a JFrame and would like to keep its width fixed and the hight resizable.
This is the code:

private void formComponentResized(java.awt.event.ComponentEvent evt) {                                       
    int ww, hh;
    Dimension wSize = this.getSize();
    ww = 420;
    hh = wSize.height;
    this.setSize(ww, hh);
}

But if I enlarge JFrame (with mouse) it goes over 420.
If I try to reduce it, it stop at the minimunwidth value set to 410 (at design time).
At design time I have set the maximumwidth = 430 but it doesn't work.
What am I doing wrong?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
ZioCrick
Offline
Joined: 2013-06-04
Points: 0

Please tell me whether I didn't explain the problem well enough or you need more details.
Thanks.
Marco

ZioCrick
Offline
Joined: 2013-06-04
Points: 0

Hi,
Nobody can help me?