JFrame大小太小 [英] JFrame size is too small
本文介绍了JFrame大小太小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在netbeans中创建了一个JFrame。但是当我运行程序时,Jframe的大小太小了。
这是我的代码。
i have created a JFrame in netbeans. But when i run the program, the Jframe size is too small. here is my code.
import javax.swing.JFrame;
public class Window {
private static void demo()
{
JFrame frame =new JFrame();
frame.setVisible(true);
}
public static void main(String[] args) {
javax.swing.SwingUtilities.invokeLater(new Runnable(){
public void run()
{
demo();
}
});
}
}
推荐答案
你可以使用 frame.setSize(width,height)
以设置其大小或 frame.setBounds(x,y,width,height)
用于设置位置和大小。
You can use frame.setSize(width, height)
in order to set its size or frame.setBounds(x, y, width, height)
for setting both the location and size.
更好的选择是调用 frame.pack()
将一些组件添加到其内容窗格后。
A better choice would be to call frame.pack()
after you add some components to its content pane.
这篇关于JFrame大小太小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文