我正在製作一個「來自地獄的圖形用戶界面」,並且我試圖讓JFrame的Flash顏色(快速更換背景)持續足夠長的時間來煩人。這是我的本錢:如何讓我的JFrame背景顏色變得狂野?
int changes = gen.nextInt(2000) + 5000;
int red;
int green;
int blue;
Color color;
for (int i = 0; i < changes; i++)
{
color = new Color(gen.nextInt(256), gen.nextInt(256),
gen.nextInt(256));
// I first tried this...
frameMain.getContentPane().setBackground(color);
// Then I tried this, which only
// appeared to change the color once and then proclaim
// that it was done:
panel1.setBackground(color);
panel2.setBackground(color);
panel3.setBackground(color);
}
注:如果你知道如何輕鬆地使整個的JFrame和它的所有內容改變顏色(不只是背景),這將是瘋狂的,真棒,所以讓我們介紹一下。
任何指導表示讚賞!希望我不只是錯過了一些愚蠢的東西......
...如果你有一個想法或兩個可笑的GUI效果,隨時分享! :)
只是爲了確保你把這個考慮:http://en.wikipedia.org/wiki/Photosensitive_epilepsy – JRL 2012-03-21 00:12:46
+1從地獄設計GUI。 – Adam 2012-03-21 00:12:47
謝謝,@亞當:) – 2012-03-21 01:51:40