java怎么写界面( 四 )


实现里面的actionPerformed方法 class MyActionListener implements ActionListener{ @Override public void actionPerformed(ActionEvent e) { index++; jl.setText("你点击了"+index+"次按钮"); } }} 。
9. 如何用JAVA编程编写一个界面程序(急求 我下面写了一个 , 初始账号和密码是 nihao 5201314 你可以改或设置
import java.awt.*;
import java.awt.event.*;
class MyDow extends Frame implements ActionListener{
private Label lName,lPassword;
private TextField tName,tPassword;
private Button login,rest,exitout;
private Label login_clew;
private int count=0;
private String myName="nihao";
private String myPassword="5201314";
public void setMyNP(String n,String p){
myName=n;
myPassword=p;
}
public MyDow(String str){
super(str);
}
public void init(){
setLayout(null);
setSize(400,300);
setVisible(true);
setResizable(false);
lName=new Label("姓名");
lName.setBounds(50, 70, 60, 30);add(lName);
lPassword=new Label("密码");
lPassword.setBounds(50, 120, 60, 30);add(lPassword);
tName=new TextField("");
tName.setBounds(110, 70, 200, 30);add(tName);
tPassword=new TextField("");
tPassword.setBounds(110, 120, 200, 30);add(tPassword);
login=new Button("登录");
login.setBounds(90, 200, 60, 30);add(login);
rest=new Button("重输");
rest.setBounds(170, 200, 60, 30);add(rest);
exitout=new Button("退出");
exitout.setBounds(250,200,60,30);add(exitout);
login_clew=new Label("");
login.addActionListener(this);
rest.addActionListener(this);
exitout.addActionListener(this);
}
public void actionPerformed(ActionEvent e){
if(e.getSource()==login){
if(count

java怎么写界面

文章插图