窗口

import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
public class zczz {
public static class z implements ActionListener {
JFrame f;
JPanel a;
JLabel c;
JButton d;
public z (){
f=new JFrame("这是一个窗口");
a=new JPanel();
c=new JLabel("click me");
d=new JButton("ok");
d.addActionListener(this);
c.setBounds(150, 82, 80, 55);
d.setBounds(50, 200, 80, 40);
a.add(c);
a.add(d);
a.setBackground(Color.pink);
f.add(a);
f.setVisible(true);
f.setSize(400, 500);
}
public void actionPerformed(ActionEvent e) {

a.setBackground(Color.blue);
c.setVisible(false);
}
public static void main(String args[]) {
new z();
}
}
}

posted on 2019-05-08 11:56  周橙梓  阅读(114)  评论(0编辑  收藏  举报

导航