java swing 最大,在java swing中设置窗口的最小大小限制

I have a JFrame which has 3 JPanels in GridBagLayout..

Now, when I minimize a windows, after a certain limit, the third JPanel tends to disappear.

I tried setting minimizing size of JFrame using setMinimumSize(new Dimension(int,int)) but no success. The windows can still be minimized.

So, I actually want to make a threshhold, that my window cannot be minimized after a certain limit.

How can I do so?

Code:-

import java.awt.Dimension;

import javax.swing.JFrame;

public class JFrameExample {

public static void main(String[] args) {

JFrame frame = new JFrame("Hello World");

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

frame.setMinimumSize(new Dimension(400, 400));

frame.setVisible(true);

}

}

Also:

shadyabhi@shadyabhi-desktop:~/java$ java --showversion

java version "1.5.0"

gij (GNU libgcj) version 4.4.1

Copyright (C) 2007 Free Software Foundation, Inc.

This is free software; see the source for copying conditions. There is NO

warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Usage: gij [OPTION] ... CLASS [ARGS] ...

to invoke CLASS.main, or

gij -jar [OPTION] ... JARFILE [ARGS] ...

to execute a jar file

Try `gij --help' for more information.

shadyabhi@shadyabhi-desktop:~/java$

Gives me output like

OMG3.png

**UPDATE: ** The same when run though Netbeans IDE gives expected output.. When I run through "java JFrameExample" compiler, I am facing issues.. Now, what that means??

解决方案

The documentation tells me, that this behavior is platform dependent. Especially, since the following example code works for me as desired in Windows Vista:

import java.awt.Dimension;

import javax.swing.JFrame;

public class JFrameExample {

public static void main(String[] args) {

JFrame frame = new JFrame("Hello World");

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

frame.setMinimumSize(new Dimension(100, 100));

frame.setVisible(true);

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值