import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class test extends JApplet
implements ActionListener{
JTextField jtf;
public void init(){
Container contentPane = getContentPane();
contentPane.setLayout(new FlowLayout());
ImageIcon ic = new ImageIcon("D:/data/Images/6.gif");
JButton jb = new JButton(ic);
jb.setActionCommand("点击了b1");
jb.addActionListener(this);
contentPane.add(jb);
ImageIcon ic1 = new ImageIcon("D:/data/Images/7.gif");
jb = new JButton(ic1);
jb.setActionCommand("点击了b2");
jb.addActionListener(this);
contentPane.add(jb);
jtf = new JTextField(15);
contentPane.add(jtf);
}
public void actionPerformed(ActionEvent ae){
jtf.setText(ae.getActionCommand());
}
}
|