I have really stuck at this point. I have the code below:
mainBoard = new JPanel(new BorderLayout());
board = new JPanel(new BorderLayout());
for(int i=0; i<4; i++){
if(i==0){
JPanel arrowPanel = new JPanel();
arrowPanel.setLayout(new FlowLayout());
for(int k =0; k<4; k++){
arrows[i][k] = new JCoordButton(up);
arrows[i][k].setPreferredSize(new Dimension(40,40));
arrowPanel.add(arrows[i][k]);
}
board.add(arrowPanel, BorderLayout.NORTH);
}
else if(i==1){
JPanel arrowPanel = new JPanel();
arrowPanel.setLayout(new FlowLayout());
for(int k =0; k<4; k++){
arrows[i][k] = new JCoordButton(right);
arrows[i][k].setPreferredSize(new Dimension(40,40));
arrowPanel.add(arrows[i][k]);
}
board.add(arrowPanel, BorderLayout.PAGE_END);
}
else if(i==2){
JPanel arrowPanel = new JPanel();
arrowPanel.setLayout(new FlowLayout());
for(int k =0; k<4; k++){
arrows[i][k] = new JCoordButton(down);
arrows[i][k].setPreferredSize(new Dimension(40,40));
arrowPanel.add(arrows[i][k]);
}
board.add(arrowPanel, BorderLayout.SOUTH);
}
else if(i==3){
JPanel arrowPanel = new JPanel();
arrowPanel.setLayout(new FlowLayout());
for(int k =0; k<4; k++){
arrows[i][k] = new JCoordButton(left);
arrows[i][k].setPreferredSize(new Dimension(40,40));
arrowPanel.add(arrows[i][k]);
}
board.add(arrowPanel, BorderLayout.PAGE_START);
}
}
board.add(colourBoard, BorderLayout.CENTER);
mainBoard.add(board, BorderLayout.CENTER);
The output is as shown below :
Untitled.png 4.66K
9 downloadsYou can imagine from my code that is not the result I want! So, what I'm doing wrong? Any idea?
Thank you,
toto_7


Sign In
Create Account


Back to top









