Topic: 请高手帮忙修改以下程序!(str1=="lcj", DONE)

  Print this page

1.请高手帮忙修改以下程序!(str1=="lcj", DONE) Copy to clipboard
Posted by: huangyinping
Posted on: 2006-04-01 11:14

此程序没有编译错误,但当用户名跟密码输入正确按登录时,老是出现清空状况,而不能显示登录成功.

import java.awt.*;
import java.applet.*;
import java.awt.event.*;

public class Xianshi extends Applet implements ActionListener{
Label lb,mima,prompt;
TextField tf1,tf2;
Button btn1;
Image myImage;

public void init() {

lb=new Label("用户");
mima=new Label("密码");
prompt=new Label();
tf1=new TextField(20);
tf2=new TextField(20);
tf2.setEchoChar('*');
btn1=new Button("登录");

myImage=getImage(getDocumentBase(),"11.jpg");
add(lb);
add(mima);
add(prompt);
add(tf1);
add(tf2);
add(btn1);

btn1.addActionListener(this);


}



public void actionPerformed(ActionEvent e) {
String str1=tf1.getText();
String str2=tf2.getText();
if(e.getSource()==btn1)
if((str1=="lcj")&&(str2=="510"))
prompt.setText("登录成功!");
else
{ tf1.setText("");
tf2.setText("");
}

}

public void paint(Graphics g)
{
g.drawImage(myImage,50,50,this);
}


}

2.Re:请高手帮忙修改以下程序! [Re: huangyinping] Copy to clipboard
Posted by: verycom
Posted on: 2006-04-01 18:16

在java中判断 字符串是否相等 是用equals()函数!==是判断两个对象是否一致


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923