java的登陆系统

来源:百度知道 编辑:UC知道 时间:2024/05/17 06:57:55
建立一个最初级的登陆界面,要求两次密码输入一致,不一致则弹出一个错误提示的框:
import java.awt.*;
import java.applet.Applet;
import java.awt.event.*;
public class FLayout extends Applet
{
public Label lab1,lab2,lab3;
public TextField txf1,txf2,txf3;
public Button bon1;
public void init()
{
setLayout(new FlowLayout(FlowLayout.CENTER,10,10));
lab1= new Label("帐号");
txf1= new TextField(10);
lab2= new Label("密码");
txf2= new TextField(10);
txf2.setEchoChar('*');
lab3= new Label("确认密码");
txf3= new TextField(10);
txf3.setEchoChar('*');
bon1= new Button("注册");
add(lab1);add(txf1);add(lab2);
add(txf2);add(lab3);
add(txf3);add(bon1);
}
public void actionPerformed(ActionEvent e)

你这里有两个错误~
1.监听Button按钮
2.判断不一样应该是if(!s2.equals(s22))

我只给你改了下错误~其他的都没有给你改动@

import java.awt.*;
import java.applet.Applet;
import java.awt.event.*;
public class FLayout extends Applet
{
public Label lab1,lab2,lab3;
public TextField txf1,txf2,txf3;
public Button bon1;
public void init()
{
setLayout(new FlowLayout(FlowLayout.CENTER,10,10));
lab1= new Label("帐号");
txf1= new TextField(10);
lab2= new Label("密码");
txf2= new TextField(10);
txf2.setEchoChar('*');
lab3= new Label("确认密码");
txf3= new TextField(10);
txf3.setEchoChar('*');
bon1= new Button("注册");
add(lab1);add(txf1);add(lab2);
add(txf2);add(lab3);
add(txf3);add(bon1);
bon1.addActionListener(new ActionListener(){ //这里,监听Button
public void actionPerformed(ActionEvent e)
{
String s1 = txf1.ge