java吧 关注:1,180,960贴子:12,576,819
  • 0回复贴,共1

翻到了刚学java时写的程序。。。当时也真是无聊。。

只看楼主收藏回复

import java.awt.Color;
import java.awt.Frame;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.ArrayList;
import java.util.List;
public class NewFourWin {
public static final int winCount = 28;
public static void main(String[] args) throws Exception {
List<FMyFrame> frames = new ArrayList<FMyFrame>(28);
for (int i = 0; i <= 1200; i += 200) {
for (int j = 0; j <= 600; j += 200) {
frames.add(new FMyFrame(i, j, 200, 200));
}
}
while (true) {
for (FMyFrame f : frames) {
f.setBackground(ABC.GG());
}
}
}
}
class ABC extends Thread {
static Color GG() {
try {
sleep(250 / NewFourWin.winCount / 2);
} catch (Exception eeed) {
}
float x = (float) Math.random();
float y = (float) Math.random();
float z = (float) Math.random();
Color a = new Color(x, y, z);
return a;
}
}
class FMyFrame extends Frame {
/**
*
*/
private static final long serialVersionUID = 1L;
static int id = 0;
static int count = 0;
static int jsxz = (int) (Math.random() * 28 + 1);
public FMyFrame(int x, int y, int w, int h) {
id++;
if (id == jsxz) {
setTitle("就是现在");
} else {
setTitle("能找到就是现在吗");
}
// setTitle(""+id);
setLayout(null);
setBounds(x, y, w, h);
setVisible(true);
setBackground(ABC.GG());
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent we) {
setVisible(false);
count++;
if (count == NewFourWin.winCount)
System.exit(0);
}
});
}
}


IP属地:日本1楼2017-08-23 11:19回复