标题:关于“cannot be resolved to a type”的问题
只看楼主
程序小怪
Rank: 1
等 级:新手上路
帖 子:13
专家分:3
注 册:2017-3-3
结帖率:66.67%
 问题点数:0 回复次数:1 
关于“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
搜索更多相关主题的帖子: cannot type new this add 
2017-09-16 09:15
程序小怪
Rank: 1
等 级:新手上路
帖 子:13
专家分:3
注 册:2017-3-3
得分:0 
原来是包导错了
2017-09-16 09:51



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-480737-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.504285 second(s), 7 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved