I designed chess board game before , i did for loop for rows and i did for loop for column ... and the result appear good . But here i want to make the board by two inner loop inside them .
I do that but the rows not appear
please any one help me .
My code:
-----------
import java.awt.BorderLayout;
import java.awt.Dimension;
import javax.swing.JFrame;
public class MovePawnTest extends JFrame {
private BoardGame board;
public MovePawnTest() {
board = new BoardGame();
getContentPane().add(board, BorderLayout.CENTER);
}
public static void main(String[] args) {
MovePawnTest movePawnTest = new MovePawnTest();
movePawnTest.setDefaultCloseOperation(MovePawnTest.EXIT_ON_CLOSE);
movePawnTest.setSize(new Dimension(600, 300));
movePawnTest.setLocationRelativeTo(null);
movePawnTest.setVisible(true);
movePawnTest.setExtendedState(MAXIMIZED_BOTH);
}
}
import java.awt.Graphics;
import javax.swing.JPanel;
public class BoardGame extends JPanel {
private final int ROW = 8, COL = 8, x = 100, y = 60;
private int[][] board;
public BoardGame() {
board = new int[ROW][COL];
}
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
drawBoard(g);
}
private void drawBoard(Graphics g) {
for (int i = 0; i < ROW; ++i) {
for (int j = 0; j < COL; ++j) {
g.drawLine((x * j) + 100, (y * i) + 60, (x * j) + 100, y * 8);
}
}
}
}
Thnaks in advance