1: 2010-07-29 (木) 10:10:10 k-tan |
現: 2024-01-08 (月) 12:58:53 lina |
| *** (1) 四角を3つ [#g78064a7] | | *** (1) 四角を3つ [#g78064a7] |
| | | |
- | grp.setColor(new Color(0xc0c0c0)); /* 背景色:やや白い灰色 */ | + | grp.setColor(new Color(0xc0c0c0)); /* 背景色:やや白い灰色 */ |
- | grp.fillRect(0, 0, dim.width, dim.height); | + | grp.fillRect(0, 0, dim.width, dim.height); |
| + | |
| + | grp.setColor(new Color(0xff0000)); /* 赤 */ |
| + | grp.fillRect( 50, 50, 150, 100); |
| + | |
| + | grp.setColor(new Color(0x00ff00)); /* 緑 */ |
| + | grp.fillRect(100, 80, 150, 100); |
| + | |
| + | grp.setColor(new Color(0x0000ff)); /* 青 */ |
| + | grp.fillRect(150, 110, 150, 100); |
| + | |
| + | repaint(); |
| | | |
- | grp.setColor(new Color(0xff0000)); /* 赤 */ | + | *** (2) 北斗七星 [#w8a8e256] |
- | grp.fillRect( 50, 50, 150, 100); | + | |
| | | |
- | grp.setColor(new Color(0x00ff00)); /* 緑 */ | + | grp.setColor(new Color(0x000080)); /* 濃い青 */ |
- | grp.fillRect(100, 80, 150, 100); | + | grp.fillRect(0, 0, dim.width, dim.height); |
| + | |
| + | grp.setColor(new Color(0xffff00)); /* 黄色 */ |
| + | grp.drawString("*", 60, 120); |
| + | grp.drawString("*", 90, 100); |
| + | grp.drawString("*", 110, 102); |
| + | grp.drawString("*", 135, 102); |
| + | grp.drawString("*", 155, 120); |
| + | grp.drawString("*", 185, 105); |
| + | grp.drawString("*", 180, 80); |
| + | |
| + | grp.setColor(new Color(0x00ff00)); /* 緑 */ |
| + | grp.drawString("北斗七星", 120, 150); |
| + | |
| + | repaint(); |
| | | |
- | grp.setColor(new Color(0x0000ff)); /* 青 */ | + | *** (3) 四角のしましま [#n24ab4c5] |
- | grp.fillRect(150, 110, 150, 100); | + | grp.setColor(new Color(0xffffff)); |
| + | grp.fillRect(0, 0, dim.width, dim.height); |
| + | |
| + | grp.setColor(new Color(0x000000)); |
| + | grp.fillRect( 20, 20, 360, 360); |
| + | grp.setColor(new Color(0xffffff)); |
| + | grp.fillRect( 40, 40, 320, 320); |
| + | grp.setColor(new Color(0x000000)); |
| + | grp.fillRect( 60, 60, 280, 280); |
| + | grp.setColor(new Color(0xffffff)); |
| + | grp.fillRect( 80, 80, 240, 240); |
| + | grp.setColor(new Color(0x000000)); |
| + | grp.fillRect(100, 100, 200, 200); |
| + | grp.setColor(new Color(0xffffff)); |
| + | grp.fillRect(120, 120, 160, 160); |
| + | |
| + | grp.setColor(new Color(0xff0000)); |
| + | grp.drawString("四角のしましま", 30, 397); |
| + | |
| + | repaint(); |
| | | |
- | repaint(); | + | *** (4) いろいろな文字 [#ie2d9294] |
- | } | + | |
- | } | + | |
| | | |
- | *** (2) 北斗七星 (ex07b.java) [#ife64f71] | + | grp.setFont(new Font("Dialog", Font.PLAIN, 12)); /* 普通の大きさ */ |
- | import java.applet.*; | + | grp.drawString("こんにちは ABC", 60, 110); |
- | import java.awt.*; | + | grp.setFont(new Font("Dialog", Font.PLAIN, 24)); /* 2倍の大きさ */ |
- | import java.awt.event.*; | + | grp.drawString("こんにちは ABC", 60, 140); |
- | import java.util.*; | + | grp.setFont(new Font("Dialog", Font.ITALIC, 24)); /* 2倍で斜体 */ |
- | | + | grp.drawString("こんにちは ABC", 60, 170); |
- | /* <applet code="ex07b.class" width="400" height="400"></applet> */ | + | grp.setFont(new Font("Dialog", Font.BOLD, 24)); /* 2倍で太字 */ |
- | | + | grp.drawString("こんにちは ABC", 60, 200); |
- | public class ex07b extends blike { | + | repaint(); |
- | public void run() | + | |
- | { | + | |
- | grp.setColor(new Color(0x000080)); /* 濃い青 */ | + | |
- | grp.fillRect(0, 0, dim.width, dim.height); | + | |
- | | + | |
- | grp.setColor(new Color(0xffff00)); /* 黄色 */ | + | |
- | grp.drawString("*", 60, 120); | + | |
- | grp.drawString("*", 90, 100); | + | |
- | grp.drawString("*", 110, 102); | + | |
- | grp.drawString("*", 135, 102); | + | |
- | grp.drawString("*", 155, 120); | + | |
- | grp.drawString("*", 185, 105); | + | |
- | grp.drawString("*", 180, 80); | + | |
- | | + | |
- | grp.setColor(new Color(0x00ff00)); /* 緑 */ | + | |
- | grp.drawString("北斗七星", 120, 150); | + | |
- | | + | |
- | repaint(); | + | |
- | } | + | |
- | } | + | |
- | | + | |
- | *** (3) 四角のしましま (ex07c.java) [#s76ad042] | + | |
- | import java.applet.*; | + | |
- | import java.awt.*; | + | |
- | import java.awt.event.*; | + | |
- | import java.util.*; | + | |
- | | + | |
- | /* <applet code="ex07c.class" width="400" height="400"></applet> */ | + | |
- | | + | |
- | public class ex07c extends blike { | + | |
- | public void run() | + | |
- | { | + | |
- | grp.setColor(new Color(0xffffff)); | + | |
- | grp.fillRect(0, 0, dim.width, dim.height); | + | |
- | | + | |
- | grp.setColor(new Color(0x000000)); | + | |
- | grp.fillRect( 20, 20, 360, 360); | + | |
- | grp.setColor(new Color(0xffffff)); | + | |
- | grp.fillRect( 40, 40, 320, 320); | + | |
- | grp.setColor(new Color(0x000000)); | + | |
- | grp.fillRect( 60, 60, 280, 280); | + | |
- | grp.setColor(new Color(0xffffff)); | + | |
- | grp.fillRect( 80, 80, 240, 240); | + | |
- | grp.setColor(new Color(0x000000)); | + | |
- | grp.fillRect(100, 100, 200, 200); | + | |
- | grp.setColor(new Color(0xffffff)); | + | |
- | grp.fillRect(120, 120, 160, 160); | + | |
- | | + | |
- | grp.setColor(new Color(0xff0000)); | + | |
- | grp.drawString("四角のしましま", 30, 397); | + | |
- | | + | |
- | repaint(); | + | |
- | } | + | |
- | } | + | |
- | *** (4) いろいろな文字 (ex07d.java) [#t0a98e3f] | + | |
- | import java.applet.*; | + | |
- | import java.awt.*; | + | |
- | import java.awt.event.*; | + | |
- | import java.util.*; | + | |
- | | + | |
- | /* <applet code="ex07d.class" width="400" height="400"></applet> */ | + | |
- | | + | |
- | public class ex07d extends blike { | + | |
- | public void run() | + | |
- | { | + | |
- | grp.setColor(new Color(0xffffff)); | + | |
- | grp.fillRect(0, 0, dim.width, dim.height); | + | |
- | grp.setColor(new Color(0x000000)); | + | |
- | grp.setFont(new Font("Dialog", Font.PLAIN, 12)); /* 普通の大きさ */ | + | |
- | grp.drawString("こんにちは ABC", 60, 110); | + | |
- | grp.setFont(new Font("Dialog", Font.PLAIN, 24)); /* 2倍の大きさ */ | + | |
- | grp.drawString("こんにちは ABC", 60, 140); | + | |
- | grp.setFont(new Font("Dialog", Font.ITALIC, 24)); /* 2倍で斜体 */ | + | |
- | grp.drawString("こんにちは ABC", 60, 170); | + | |
- | grp.setFont(new Font("Dialog", Font.BOLD, 24)); /* 2倍で太字 */ | + | |
- | grp.drawString("こんにちは ABC", 60, 200); | + | |
- | repaint(); | + | |
- | } | + | |
- | } | + | |