import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
@SuppressWarnings("serial")
public class simple extends JFrame implements ActionListener {
JTextField jt=new JTextField();
JButton jb1,jb2;
simple(){
JPanel jp=new JPanel();
jp.setLayout(new GridLayout(3,1));
jb1=new JButton("按键");
jb1.addActionListener(this);
jb2=new JButton("清空");
jb2.addActionListener(this);
jp.add(jt);
jp.add(jb1);
jp.add(jb2);
setVisible(true);
setSize(200,100);
setContentPane(jp);
}
public void actionPerformed(ActionEvent e) {
String s =e.getActionCommand();
if(s.equals("按键")){
jt.setText("按键");
}
else
jt.setText("");
}
public static void main(String[] args){
new simple();
}
}
计算器
最新推荐文章于 2020-04-03 22:09:43 发布