New initFields method in GameGui
parent
7394548cc5
commit
db7e2a9f5a
|
|
@ -32,6 +32,7 @@ public class GameGui {
|
|||
private JScrollPane moveListScroll;
|
||||
|
||||
public GameGui(){
|
||||
initFields();
|
||||
mainFrame();
|
||||
}
|
||||
|
||||
|
|
@ -47,6 +48,22 @@ public class GameGui {
|
|||
return frame;
|
||||
}
|
||||
|
||||
private void initFields() {
|
||||
for (int row = 0; row < 8; row++) {
|
||||
for (int col = 0; col < 8; col++) {
|
||||
JLabel label = new JLabel("", SwingConstants.CENTER);
|
||||
label.setOpaque(true);
|
||||
label.setFont(new Font("Serif", Font.BOLD, 40));
|
||||
if ((row + col) % 2 == 0) {
|
||||
label.setBackground(new Color(0x778da9));
|
||||
} else {
|
||||
label.setBackground(new Color(0xe0e1dd));
|
||||
}
|
||||
fields[row][col] = label;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public JPanel mainPanel() {
|
||||
JPanel mainPanel = new JPanel(new GridBagLayout());
|
||||
GridBagConstraints gbc = new GridBagConstraints();
|
||||
|
|
@ -59,7 +76,7 @@ public class GameGui {
|
|||
gbc.insets = new Insets(5, 5, 5, 0);
|
||||
//oben, links, unten, rechts
|
||||
gbc.fill = GridBagConstraints.BOTH;
|
||||
mainPanel.add(chessPanel(boardPanel()),gbc);
|
||||
mainPanel.add(chessPanel(boardPanel()), gbc);
|
||||
|
||||
// Rechts (Stats)
|
||||
gbc.gridx = 1;
|
||||
|
|
@ -145,6 +162,7 @@ public class GameGui {
|
|||
return statsPanel;
|
||||
}
|
||||
|
||||
|
||||
public void updateMoveList(List<String> moves) {
|
||||
moveListPanel.removeAll();
|
||||
for (String move : moves) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue