一直找不到符号,怎么解决

package com.task17;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Login extends JFrame implements ActionListener
{
JPanel jp;
JLabel name;
JLabel password;
JLabel show;
JTextField jName;
JPasswordField jPassword;
JButton login;
JButton reset;
JButton register;
public Login(){
jp = new JPanel();
name = new JLabel("输入用户名:");
password = new JLabel("输入密码");
show = new JLabel("");
login = new JButton("登录");
reset = new JButton("重置");
register = new JButton("注册");
jName = new JTextField(10);
jPassword = new JPasswordField(10);
jPasswordField.setEchoChar('*');
jp.add(name);
jp.add(jName);
jp.add(password);
jp.add(jPassword);
jp.add(login);
jp.add(reset);
jp.add(register);
jp.add(show);
login.addActionListener(this);
reset.addActionListener(this);
register.addActionListener(this);
this.setContentPane(jp);
this.setTitle("登录窗口");
this.setSize(340,260);
boolean Visible;
this.setVisible(true);
this.setDefauleCloseOperation("JFrame.EXIT_ON_CLOSE");
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==reset){
show.setText("");
jName.setText("");
jPassword.setText("");
}
else if(e.getSource()==register){
show.setText("进入注册页面");
}
else{
if(jName.getText().equals("nonglin")&&String.valueOf(jPassword.getPassword()).equals("201600")){
show.setText("登录成功");}
else{
show.setText("对不起!用户名或密码不对");}
}}
public static void main(String args[]){
new Login();
}
}

 

2个问题:

第一个问题:控件名称写错了

jPasswordField.setEchoChar('*');

改为

jPassword.setEchoChar('*');

第二个问题:删除双引号

this.setDefauleCloseOperation("JFrame.EXIT_ON_CLOSE");

改为

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

jPasswordField.setEchoChar('*');

应该是jPassword.setEchoChar('*');

第二处错误:修改为

this.setDefauleCloseOperation(JFrame.EXIT_ON_CLOSE);

您好,我是有问必答小助手,您的问题已经有小伙伴解答了,您看下是否解决,可以追评进行沟通哦~

如果有您比较满意的答案 / 帮您提供解决思路的答案,可以点击【采纳】按钮,给回答的小伙伴一些鼓励哦~~

ps:问答VIP仅需29元,即可享受5次/月 有问必答服务,了解详情>>>https://vip.csdn.net/askvip?utm_source=1146287632