已写有如下代码:importjava.awt.*;importjava.awt.event.ActionEvent;importjava.awt.event.ActionListener;importjava.awt.event.TextListener;importjava.applet.Applet;publiccla...
已写有如下代码:import java.awt.*;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.event.TextListener;import java.applet.Applet;public class ds extends Applet implements ActionListener{ Label lab1=new Label("用户名"); Label lab2=new Label("密码"); Label lab3=new Label("登陆界面"); Button but1=new Button("确定"); Button but2=new Button("取消"); TextField name=new TextField (10); TextField pwd=new TextField (10); public void init() { setLayout(null); add(lab1); lab1.setBounds(10, 10, 40,20); add(lab3); lab3.setBounds(50, 100, 150,20); add(lab2); lab2.setBounds(10, 50, 40,20); add(but1); but1.setBounds(30,150, 50,30); add(but2); but2.setBounds(100,150, 50,30); add(name); name.setBounds(60,10, 100,20); add(pwd); pwd.setEchoChar('*'); pwd.setBounds(60,50, 100,20); but1.addActionListener(this); but2.addActionListener(this); }public void actionPerformed(ActionEvent e){Object s=e.getSource();if(s==but1){ if(name.getText().length()==0) lab3.setText("用户名不能为空");else if (pwd.getText().length()==0) lab3.setText("密码不能为空");else if(name.getText().equals(pwd.getText())) lab3.setText("欢迎登录");else lab3.setText("登录失败,请重新登录"); }if(s==but2) System.exit(0);}public static void main (String[]args){ ds t=new ds(); }}现在要在上面的代码加上该问题的代码``怎么加``速速```
展开