setMaximumSize not working in java(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:
这是一个已知的错误:
- http://bugs.sun.com/bugdatabase/view_bug.做;?bug_id=6200438
- http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4744281
- http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4320050
也许你可以使用
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中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:setMaximumSize 在java中不起作用
基础教程推荐
- 存储 20 位数字的数据类型 2022-01-01
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
- RabbitMQ:消息保持“未确认"; 2022-01-01
- 如何对 Java Hashmap 中的值求和 2022-01-01
- 使用堆栈算法进行括号/括号匹配 2022-01-01
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
- Struts2 URL 无法访问 2022-01-01
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- 修改 void 函数的输入参数,然后读取 2022-01-01
