JFrame 尺寸太小 [英] JFrame size is too small

查看:19
本文介绍了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();
      }
        });
    }
}

解决方案

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.

A better choice would be to call frame.pack() after you add some components to its content pane.

这篇关于JFrame 尺寸太小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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