import javax.swing.*; import java.awt.*; /* */ public class Othello extends JApplet { @Override public void paint(Graphics g) { super.paint(g); int scale = 40; int space = 3; 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}}; 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 frame = new JFrame(""); JApplet applet = new Othello(); applet.setPreferredSize(new Dimension(480, 480)); frame.add(applet); frame.pack(); frame.setVisible(true); applet.init(); applet.start(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } }