?? randomcolor.java
字號(hào):
//==============================================================
// RandomColor.java - Delegation event model using anonymous class
//
// Java學(xué)習(xí)源代碼檢索系統(tǒng) Ver 1.0 20031015 免費(fèi)正式版
// 版權(quán)所有: 中國(guó)IT認(rèn)證實(shí)驗(yàn)室(www.ChinaITLab.com)
// 程序制作: ChinaITLab網(wǎng)校教研中心
// 主頁(yè)地址: www.ChinaITLab.com 中國(guó)IT認(rèn)證實(shí)驗(yàn)室
// 論壇地址: bbs.chinaitlab.com
// 電子郵件: Java@ChinaITLab.com
//==============================================================
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import java.util.Random;
public class RandomColor extends Applet {
// Constructor
public RandomColor() {
// Create GUI button object and random generator
Button clickMe = new Button("Click Me!");
final Random gen = new Random();
// Create listener using an anonymous class
clickMe.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Color c;
do {
c = new Color(gen.nextInt());
} while (c == getBackground());
setBackground(c);
repaint();
}
});
// Add button to Applet container
add(clickMe);
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -