import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.AdjustmentListener;
import javax.swing.*;
public class ck implements ActionListener {
JFrame a;
JButton b1;
JLabel b2;
JPanel b;
public ck() {
a = new JFrame();
b = new JPanel();
b1 = new JButton("确定");
b2 = new JLabel("改变面板颜色?");
b1.addActionListener(this);
a.setVisible(true);
a.setSize(400, 300);
b.add(b2);
b.add(b1);
a.add(b);
}
public static void main(String[] args) {
new ck();
}
public void actionPerformed(ActionEvent e) {
b.setBackground(Color.blue);
}
}
运行结果: