Наконец, что-то для удовольствия ... Попробуй. Используйте его как любой JFrame.
class JFrameWild extends JFrame {
private static final long serialVersionUID = 666L;
public JFrameWild(String string) {
super(string);
Thread thread = new Thread(new Runnable() {
public void run() {
while (true) {
yoyoMama(JFrameWild.this);
try {
Thread.sleep(300);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
});
thread.setDaemon(true);
thread.start();
}
private void yoyoMama(Object object) {
if (object instanceof Container) {
Container c = (Container) object;
Component[] components = c.getComponents();
for (Component component : components) {
yoyoMama(component);
// put extra "wild" stuff here
component.setBackground((new Color((int) (Math.random() * (double) (0xFFFFFF)))));
}
} else {
if (object instanceof Component) {
Component component = (Component) object;
// put extra "wild" stuff here
component.setBackground((new Color((int) (Math.random() * (double) (0xFFFFFF)))));
}
}
}
}