Skip to content

Instantly share code, notes, and snippets.

@fcflyinsky
Created February 20, 2014 13:03
Show Gist options
  • Save fcflyinsky/9113049 to your computer and use it in GitHub Desktop.
Save fcflyinsky/9113049 to your computer and use it in GitHub Desktop.
package Ex13;
import java.applet.Applet;
import java.awt.*;
public class Ex13_202 extends Applet {
public void init() {
// 設定Applet背景顏色
this.setBackground(Color.white);
// 設定視窗大小
setSize(250, 250);
}
public void paint(Graphics g) {
g.setColor(Color.green);
g.drawString("中空矩形", 20, 20);
// g.drawRect(基準點x, 基準點y, 長, 寬);
g.drawRect(20, 25, 80, 80);
g.setColor(Color.blue);
g.drawString("填滿矩形", 120, 20);
// g.fillRect(基準點x, 基準點y, 長, 寬);
g.fillRect(120, 25, 80, 80);
g.setColor(Color.orange);
g.drawString("圓角矩形", 20, 120);
// g.drawRoundRect(基準點x, 基準點y, 長, 寬, 圓角弧度, 圓角弧度);
g.drawRoundRect(20, 125, 80, 80, 15, 15);
g.setColor(Color.red);
g.drawString("填滿圓角矩形", 120, 120);
// g.fillRoundRect(基準點x, 基準點y, 長, 寬, 圓角弧度, 圓角弧度);
g.fillRoundRect(120, 125, 80, 80, 15, 15);
// 更改狀態列文字
showStatus("繪圖視窗");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment