setMaximumSize 在java中不起作用 [英] setMaximumSize not working in java

查看:20
本文介绍了setMaximumSize 在java中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有 JFrame 的 java 程序

I hava a java program with a JFrame

我使用的是绝对定位

这是我的主要功能

public static void main(String[] args) {
    ape Ape = new ape();
    Ape.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Ape.setSize(1000,1000);
    Ape.setMinimumSize(new Dimension(1000,1000));
    Ape.setMaximumSize(new Dimension(1000,1000));
    Ape.setVisible(true);
}

当我运行程序时,我尝试调整它的大小并使窗口变小,但我做不到

When I run the program I try to resize it and make the window smaller but I can't

当我尝试使窗口更大时它工作正常我基本上跳过了 setMaximumSize() 函数

when I try to make the window bigger it works fine I basicly skips the setMaximumSize() function

我已经阅读过,显然之前发生过这种情况

I have read around and aparently this has happened before

这是一个已知的错误吗?

is this a known bug?

如果是这样,我听说我可以制作一个 Window Listener,当我尝试它时,我实现了 WindowListener 所需的功能,但找不到任何东西来解决我的问题

if so I heard I could make a Window Listener, when I tried it I implemented the functions that WindowListener needed but could not find anything to solve my problem

请自己尝试一下,看看会发生什么......

please try this yourself and see what happens...

提前致谢

PS...请不要嘲笑我给我的班级起的名字...:)

PS... please don't laugh about the names I give my classes... :)

推荐答案

参见http://forums.sun.com/thread.jspa?threadID=5342801:

这是一个已知的错误:

也许你可以使用

Ape.setResizable(false)

改为?

PS:按照惯例,类名以大写字母开头,变量名以小写字母开头,反之亦然.

PS: It's a convention to give classes names that start with a capital letter and variables ones with a small letter, not vice versa.

这篇关于setMaximumSize 在java中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆