Java JFrame - 不工作

时间:2011-03-01 12:27:57

标签: java swing jframe

试图用JFrame创建一个窗口。对于'新JFrame'总是说“找不到synbol”

import java.awt.*; 
import javax.swing.*; 

public class window {
    public static void createWindow() {
        JFrame frame = new Jframe("Simple GUI");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
}

问题: JFrame必须有大写字母“F”

3 个答案:

答案 0 :(得分:3)

JFrame frame = new JFrame("Simple GUI");
                    ^---

Java区分大小写。 Jframe与JFrame不同。

答案 1 :(得分:1)

尝试添加像这样的主要方法

import java.awt.*; 
import javax.swing.*; 

public class window 
{
    public static void createWindow() 
    {
        JFrame frame = new JFrame("Simple GUI");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);    //set closing bebavior
        frame.setSize(400, 400);                                 //set the size of jframe
        frame.setLocationRelativeTo(null);                       //center the jframe 
        frame.setVisible(true);                                  //show the frame
    }
    //main method  
    public static void main(String[] args) 
    {
        createWindow();//launch your creaWindow method  
    }
}

答案 2 :(得分:0)

JFrame中的F不能小写,将其从Jframe更改为JFrame。它应该在之后工作