package screen;
import java.awt.Color;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
public class textFrame implements ActionListener {
JFrame f;
JPanel p;
JLabel l;
JButton b1;
JButton b2;
public textFrame(){
f = new JFrame("text");
p = new JPanel(new GridLayout(1,2,5,5));
l = new JLabel("测试");
b1 = new JButton("变色");
f.add(p);
p.add(l);
p.add(b1);
f.setSize(400, 300);
f.setVisible(true);
b1.addActionListener(this);
}
public static void main(String[] args) {
new textFrame();
}
@Override
public void actionPerformed(ActionEvent e) {
p.setBackground(new Color((int)(Math.random()*255),(int)(Math.random()*255),(int)(Math.random()*255)));
l.setLocation((int)(Math.random()*110),(int)(Math.random()*110));
}
}