📄 app18_10.java
字号:
// app18_10, 以不同颜色的小圆形铺满窗口
import java.awt.*;
class app18_10 extends Frame
{
static app18_10 frm=new app18_10();
public static void main(String args[])
{
frm.setTitle("Random Color");
frm.setSize(200,150);
frm.setVisible(true);
}
public void paint(Graphics g)
{
for(int x=10;x<=180;x=x+20)
for(int y=27;y<=140;y=y+20)
{
int red=(int)(Math.random()*255); // 红色的随机数
int green=(int)(Math.random()*255); // 绿色的随机数
int blue=(int)(Math.random()*255); // 蓝色的随机数
g.setColor(new Color(red,green,blue)); // 设置颜色
g.fillOval(x,y,15,15); // 用指定的眼色填满小圆
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -