📄 driver.java
字号:
import javax.swing.JFrame;import java.awt.Color;/** PolkaDot Program (Figure 10.14) * Author: David Riley * Date: January, 2005 */public class Driver { private JFrame window; public Driver() { int yCount, xCount; Oval dot; Color rowColor; window = new JFrame("Polkadots"); window.setBounds(10, 10, 200, 200); window.setVisible(true); window.setLayout(null); yCount = 0; while ( yCount != 12 ) { rowColor = new Color(yCount/13.0f, yCount/13.0f, yCount/13.0f); // rowColor is gray an intensity of yCount/13. // (0.0f is black and 1.0f is white) xCount = 0; while ( xCount != 8 ) { dot = new Oval(xCount*25, yCount*15, 10, 10); dot.setBackground(rowColor); window.add(dot, 0); xCount++; } yCount++; } window.repaint(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -