标题:前辈些帮忙解决下吧 。
只看楼主
林浩
Rank: 2
等 级:论坛游民
帖 子:47
专家分:23
注 册:2011-1-12
结帖率:90.91%
已结贴  问题点数:10 回复次数:3 
前辈些帮忙解决下吧 。
怎么总是报下面错的呢?


package register;

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

public class MyRegisterFrame extends JFrame
{   
    public void CreatRegisterFrame(String title)
    {
        final JFrame jf = new JFrame(title); //定义容器和各部件;
        Container c = jf.getContentPane();
        JLabel jl1 = new JLabel("用户名");
        JLabel jl2 = new JLabel("密码");
        final JTextField jt  = new JTextField("");
        final JPasswordField jp = new JPasswordField("");
        JButton jb1 = new JButton("登陆");
        JButton jb2 = new JButton("重置");
        
        jf.setSize(600, 400);
        jf.setVisible(true);
        c.setBackground(Color.blue);
        
        c.add(jl1);  //添加各部件到容器;
        c.add(jl2);
        c.add(jt);
        c.add(jp);
        c.add(jb1);
        c.add(jb2);
        
        jl1.setBounds(150, 100, 10, 5);
        jl2.setBounds(150, 105, 10, 5);
        jt.setBounds(160, 100, 20, 5);
        jp.setBounds(160, 105, 20, 5);
        jb1.setBounds(180, 115, 10, 5);
        jb2.setBounds(195, 115, 10, 5);
        jp.setEchoChar('*');
        
        jb1.addActionListener(new ActionListener()  //为“登陆”按钮添加监听事件;
        {
            public void actionPerformed(ActionEvent e)
            {
                if (jt.getText() == "mr" && jp.getText() == "mrsoft")
                {
                    new MyDialog(jf, "登陆成功").setVisible(true);
                }
                else
                {
                    new MyDialog(jf, "用户名或密码错误").setVisible(true);
                }
            }
            
        });
        
        jb2.addActionListener(new ActionListener()  //为“重置”按钮添加监听事件;
        {
            public void actionPerformed(ActionEvent e)
            {
                jt.setText("");
                jp.setText("");
            }
            
        });
                    
        jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    }
   
    public static void main(String[] args)
    {
        new MyRegisterFrame().CreatRegisterFrame("用户登陆窗口");
    }
}

class MyDialog extends JDialog   //自定义对话框类;
{
    public MyDialog(JFrame jf, String str)
    {
        super(jf, "提示信息", true);
        Container c = getContentPane();
        c.add(new JLabel(str));        
        c.setSize(100, 100);   
    }
}
Description    Resource    Path    Location    Type
ActionListener cannot be resolved to a type    MyRegisterFrame.java    RegisterFrame/src/register    line 39    Java Problem
Description    Resource    Path    Location    Type
ActionListener cannot be resolved to a type    MyRegisterFrame.java    RegisterFrame/src/register    line 55    Java Problem


Description    Resource    Path    Location    Type
ActionListener cannot be resolved to a type    MyRegisterFrame.java    RegisterFrame/src/register    line 39    Java Problem
搜索更多相关主题的帖子: 密码 register package public 用户名 
2011-10-29 19:46
付政委
该用户已被删除
得分:5 
提示: 作者被禁止或删除 内容自动屏蔽
2011-10-29 21:06
林浩
Rank: 2
等 级:论坛游民
帖 子:47
专家分:23
注 册:2011-1-12
得分:0 
回复 2楼 付政委
import java.awt.Event.*;
这个不就包含了你那两个包了 吗??
2011-10-29 21:59
baifenghan
Rank: 8Rank: 8
等 级:贵宾
威 望:10
帖 子:258
专家分:952
注 册:2006-3-17
得分:5 
在我的环境上没有报错,你说的对,是包含了这两个包。
2011-10-30 17:38



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




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

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