import javax.swing.*; import java.awt.*; /* */ public class Othello extends JApplet { int scale = 40; int space = 3; int size = 8; int[][] state = {{0,1,2,0,1,2,0,1}, {2,0,1,2,0,1,2,0}, {1,2,0,1,2,0,1,2}, {0,1,2,0,1,2,0,1}, {2,0,1,2,0,1,2,0}, {1,2,0,1,2,0,1,2}, {0,1,2,0,1,2,0,1}, {2,0,1,2,0,1,2,0}}; @Override public void paint(Graphics g) { int i,j; for (i=0; i<8; i++) { for (j=0; j<8; j++) { g.setColor(Color.GREEN); g.fillRect(i*scale, j*scale, scale, scale); g.setColor(Color.BLACK); g.drawRect(i*scale, j*scale, scale, scale); if (state[i][j]==1) { g.setColor(Color.WHITE); g.fillOval(i*scale+space, j*scale+space, scale-space*2, scale-space*2); } else if (state[i][j]==2) { g.setColor(Color.BLACK); g.fillOval(i*scale+space, j*scale+space, scale-space*2, scale-space*2); } } } } /* public static void main(String args[]) { JFrame f; JApplet a; f = new JFrame(); a = new Othello(); // 現在、定義しているクラスのコンストラクタ a.init(); // アプレットを初期化 f.getContentPane().add(a); f.setDefaultCloseOperation(3); f.setSize(330, 360); // アプレットよりも少し大きめのサイズにする。 f.setVisible(true); // 必要なら a.start()を呼ぶ } */ }