我想要获取Jframe的当前尺寸,只要点击button1即可。这是我在button1clickevent中写的代码,最初当我点击按钮时,我得到了宽度和高度,但是当我更改Jframe的大小,然后再次单击button1时,我得到的宽度和高度与我的相同得到更早。价值不会随时改变。如何在运行时获得JFrame的当前尺寸
AppDisplay ap=new AppDisplay(); //class which has got the JFrame
int f12;
f12=ap.getContentPane().getSize().width;
System.out.println(f12+"\n");
f12=ap.getContentPane().getSize().height;
System.out.println(f12);
这样的结果是包后'有效()'上该框架的“窗口”。 – trashgod 2012-07-29 23:30:14