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

查看:417
本文介绍了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

这是一个已知错误吗?

如果是这样我听说我可以制作一个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... :)

推荐答案

参见< a href =http://forums.sun.com/thread.jspa?threadID=5342801\"rel =nofollow noreferrer> http://forums.sun.com/thread.jspa?threadID=5342801 :

这是一个已知的错误:

  • http://bugs.sun.com/bugdatabase/view_bug.do;?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中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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