这个java程序添加一个关闭按钮,并且能实现关闭窗口
importjava.awt.*;importjava.applet.*;importjava.awt.event.*;publicclasssimpleEventext...
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class simpleEvent extends Applet implements ActionListener
{
Label lb;
TextField in;
TextField out;
public void init()
{
lb=new Label("请输入您的名字");
in=new TextField(6);
out=new TextField(20);
add(lb);
add(in);
add(out);
in.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
out.setText(in.getText()+" 欢迎光临! ");
}
} 展开
import java.applet.*;
import java.awt.event.*;
public class simpleEvent extends Applet implements ActionListener
{
Label lb;
TextField in;
TextField out;
public void init()
{
lb=new Label("请输入您的名字");
in=new TextField(6);
out=new TextField(20);
add(lb);
add(in);
add(out);
in.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
out.setText(in.getText()+" 欢迎光临! ");
}
} 展开
1个回答
2013-11-04
展开全部
package test;import java.awt.*;
import java.applet.*;
import java.awt.event.*;import javax.swing.JButton;public class SimpleEvent extends Applet implements ActionListener {
Label lb;
TextField in;
TextField out;
Button button; public void init() {
lb = new Label("请输入您的名字");
in = new TextField(6);
out = new TextField(20);
button=new Button("关闭");
add(lb);
add(in);
add(out);
add(button);
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
});
in.addActionListener(this);
} public void actionPerformed(ActionEvent e) {
}
}
import java.applet.*;
import java.awt.event.*;import javax.swing.JButton;public class SimpleEvent extends Applet implements ActionListener {
Label lb;
TextField in;
TextField out;
Button button; public void init() {
lb = new Label("请输入您的名字");
in = new TextField(6);
out = new TextField(20);
button=new Button("关闭");
add(lb);
add(in);
add(out);
add(button);
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
});
in.addActionListener(this);
} public void actionPerformed(ActionEvent e) {
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询