关于“cannot be resolved to a type”的问题
import javax.swing.*;import javax.awt.event.*;
import javax.awt.*;
public class Test02 extends JFrame {
//窗口的创建方法
public void CreateFrame(){
JPanel jp1=new JPanel();
JPanel jp2=new JPanel();
JPanel jp3=new JPanel();
JLabel jl1=new JLabel("用户名:");
JLabel jl2=new JLabel("密码:");
JButton jb1=new JButton("登录");
JButton jb2=new JButton("重置");
JTextField jtf=new JTextField(10);
JPasswordField jpf=new JPasswordField(10);
this.setLayout(new GridLayout(3,1));
jp1.add(jl1);
jp1.add(jtf);
jp2.add(jl2);
jp2.add(jpf);
jp3.add(jb1);
jp3.add(jb2);
this.add(jp1);
this.add(jp2);
this.add(jp3);
this.setTitle("示例窗口");
//this.pack();
this.setSize(800,600);
this.setLocationRelativeTo(null);
this.setVisible(true);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
}
public static void main(String[] args){
Test02 frame1=new Test02();
frame1.CreateFrame();
}
}
为什么会提示错误Exception in thread "main" java.lang.Error: Unresolved compilation problem:
GridLayout cannot be resolved to a type