前辈些帮忙解决下吧 。
怎么总是报下面错的呢?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