import java.awt.*;//陈展鹏
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import javax.swing.*;
public class ChenZhanpeng {
    static JTextField edit;
    static JButton an1,an2,an3,an4,an5,an6,an7,an8,an9,an10,an11,an12,an13,an14,an15,an16,an17,an18;
    public static void main(String[]args){
        JFrame jf=new JFrame("猪式计算器");
        jf.addWindowListener(new WindowListener(){
            public void windowActivated(WindowEvent e) {
                System.out.println("欢迎您使用猪式计算器");
                
            }
            public void windowClosed(WindowEvent e) {
        
                
            }
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            
                
            }
            public void windowDeactivated(WindowEvent e) {
                
                
            }
            public void windowDeiconified(WindowEvent e) {
                
                
            }
            public void windowIconified(WindowEvent e) {
                
                
            }
            public void windowOpened(WindowEvent e) {
                
                
            }
            
        });
        jf.setSize(320,300);
        Container c=jf.getContentPane();
        
        c.setLayout(new GridLayout(4,5,8,8));
        an1=new JButton("<html><h1>1");
        an2=new JButton("<html><h1>2");
        an3=new JButton("<html><h1>3");
        an4=new JButton("<html><h1>4");
        an5=new JButton("<html><h1>5");
        an6=new JButton("<html><h1>6");
        an7=new JButton("<html><h1>7");
        an8=new JButton("<html><h1>8");
        an9=new JButton("<html><h1>9");
        an10=new JButton("<html><h1>.");
        an11=new JButton("<html><h1>+");
        an12=new JButton("<html><h1>-<h1></html>");
        an13=new JButton("<html><h1>*");
        an14=new JButton("<html><h1>/");
        an15=new JButton("<html><h1>=");
        an16=new JButton("<html><h1>0");
        an17=new JButton();
        an17.setText("<html><h2>清零<h2></html>");
        an18=new JButton("<html><h2>退格");
        edit=new JTextField();
        edit.setSize(300, 50);
        c.add(edit);
        c.add(an1);
        c.add(an2);
        c.add(an3);
        c.add(an4);
        c.add(an5);
        c.add(an6);
        c.add(an7);
        c.add(an8);
        c.add(an9);
        c.add(an10);
        c.add(an11);
        c.add(an12);
        c.add(an13);
        c.add(an14);
        c.add(an15);
        c.add(an16);
        c.add(an17);
        c.add(an18);
        jf.setVisible(true);
    }
}
class jtq implements ActionListener{
    public void actionPerformed(ActionEvent e) {
        Object a=e.getSource();
        JButton t;
        t=(JButton)a;
        if(t.getText().equals("清零")){
            
        }
    
        
    }
    
}
 这段代码中,我添加了ActionListener监听器,我想实现,单击清零按钮的时候,edit文本框显示""为空,单击1,2,3。。。。。按钮分别在文本框JTextField edit中显示相应的数字,怎么实现。。。我编不下去了,请高手指点。

 
											





 
	    



 
										
					
	