标签:string http his 背景 实现 visible png mamicode bsp
完成一个按钮的事件处理程序,实现功能自拟,例如:改变窗口的背景颜色,改变按钮的位置等等
package ccc;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
public class window implements ActionListener{
JFrame f;
JButton s;
JLabel p;
JPanel a;
public window() {
f=new JFrame();
s=new JButton("点击");
p=new JLabel();
a=new JPanel();
s.addActionListener(this);
f.setSize(800,600);
f.setVisible(true);
f.add(a);
a.add(s);
a.add(p);
}
public static void main(String[]arge){
new window();
}
public void actionPerformed(ActionEvent e) {
a.setBackground(Color.yellow);
}
}
标签:string http his 背景 实现 visible png mamicode bsp
原文地址:https://www.cnblogs.com/lgm1418973707/p/10851207.html