package javaFrame;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.FlowLayout;
public class FrameEx2 implements ActionListener{
JFrame jf;
JPanel jp;
JButton button1,button2;
TextArea tf1;
public FrameEx2(){
jf = new JFrame("小小菜");
button1 = new JButton("呼呼呼呼呼呼呼呼呼呼呼呼!");
button2 = new JButton("啦啦啦啦啦啦啦啦啦啦啦啦!");
Label label1 = new Label("监听听到的");
tf1 = new TextArea();
jp = new JPanel();
jf.setVisible(true);
button1.addActionListener(new secondbutton());
button2.addActionListener(new firstbutton());
jp.add(button1);
jp.add(button2);
jf. setLayout(new GridLayout(5,1));
jf.add(label1);
jf.add(tf1);
jf.add(jp);
jf.setSize(500,300);
}
public static void main(String[] args) {
FrameEx2 action = new FrameEx2();
}
public void actionPerformed(ActionEvent e) {
}
class secondbutton implements ActionListener{
public void actionPerformed(ActionEvent e) {
tf1.append("这是左边,"+e.getActionCommand()+"\n\n");
}
}
class firstbutton implements ActionListener{
public void actionPerformed(ActionEvent e) {
tf1.append("这是右边,"+e.getActionCommand()+"\n\n");
}
}
}