java
1package othello; 2 3import java.awt.Color; 4import java.awt.Dimension; 5import java.awt.Graphics; 6import javax.swing.JPanel; 7import static othello.CommonConstants.*; 8public class Board extends JPanel { 9 10 11 public Board() { 12 setPreferredSize(new Dimension(WIDETH, HEGHT)); 13 addMouseListener(new Decision()); 14 } 15 16 public void paintComponent(Graphics graphi) { 17 18 // 背景 19 graphi.setColor(BOARDCOLOR); 20 graphi.fillRect(0, 0, WIDETH, HEGHT); 21 22 // 線 23 graphi.setColor(LINECOLOR); 24 for (int i = 0; i < 8; i++) { 25 graphi.drawLine(0, i * SIZE, WIDETH, i * SIZE); 26 graphi.drawLine(i * SIZE, 0, i * SIZE, HEGHT); 27 } 28 // 駒 29 // graphi.setColor(Color.DARK_GRAY); 30 // for(int y=0; y<8; y++){ 31 // for(int x=0; x<8; x++){ 32 // 33 // } 34 // } 35 } 36} 37 38``` 39```java 40package othello; 41 42import java.awt.Color; 43 44public class CommonConstants { 45 46 // 一つのマスの大きさ 47 public final int SIZE = 100; 48 //マスの数 49 public final int MASS = 8; 50 // 縦の幅 51 public final int HEGHT = SIZE * MASS; 52 // 横の幅 53 public final int WIDETH = SIZE * MASS; 54 // ボードの色 55 public final Color BOARDCOLOR = Color.GREEN; 56 // ボードの線の色 57 public final Color LINECOLOR = Color.BLACK; 58 //配列の大きさ 59 public final int [][] BOARD_ARRAY = new int[MASS][MASS]; 60} 61 62``` 63import staticを使用してみたのですが、定数にクラスがないと使用できません。何か足りないものがありますでしょうか?
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。