added gridUpdate to refrech gameGrid after user press to revalidate
colors of buttonsgui
parent
1e640026f7
commit
6a505ef34d
|
@ -14,7 +14,8 @@ import javax.swing.JPanel;
|
|||
import de.hs_mannheim.informatik.pr2projekt.domain.HitoriMain;
|
||||
|
||||
public class GameGUI {
|
||||
private static void paintGame(String[] filepath, JButton[][] buttons, String[][] colors, Stack<String> madeMoves, String[][] data){
|
||||
|
||||
public static void paintGame(String[] filepath, JButton[][] buttons, String[][] colors, Stack<String> madeMoves, String[][] data){
|
||||
JFrame frame = new JFrame();
|
||||
int num = buttons.length;
|
||||
JPanel gameGrid = new JPanel(new GridLayout(num,num,0,0));
|
||||
|
@ -40,9 +41,9 @@ public class GameGUI {
|
|||
MenuGUI.getPath(filepath);
|
||||
});
|
||||
JButton b1 = new JButton("Zurück");
|
||||
b1.addActionListener(e -> {backOneStep(madeMoves, buttons, colors,gameGrid);});
|
||||
b1.addActionListener(e -> {HitoriMain.backOneStep(madeMoves, buttons, colors, gameGrid);});
|
||||
JButton b2 = new JButton("Zurücksetzen");
|
||||
b2.addActionListener(e -> {totalResetButton(buttons, colors, madeMoves, data);});
|
||||
b2.addActionListener(e -> {HitoriMain.totalResetButton(buttons, colors, madeMoves, data);});
|
||||
JButton b3 = new JButton("Abgeben");
|
||||
String path = filepath[0];
|
||||
b3.addActionListener(e -> {
|
||||
|
@ -69,7 +70,7 @@ public class GameGUI {
|
|||
frame.setSize(600,600);
|
||||
}
|
||||
|
||||
private static void paintButton(JButton b, String[] pos, String[][] colors, Stack<String> madeMoves){
|
||||
public static void paintButton(JButton b, String[] pos, String[][] colors, Stack<String> madeMoves){
|
||||
int i = Integer.parseInt(pos[0]);
|
||||
int j = Integer.parseInt(pos[1]);
|
||||
String col = colors[Integer.parseInt(pos[0])][Integer.parseInt(pos[1])];
|
||||
|
@ -106,5 +107,18 @@ public class GameGUI {
|
|||
String logEntrance = i+"."+j+"."+"W";
|
||||
madeMoves.push(logEntrance);
|
||||
}
|
||||
|
||||
public static void gridUpdate(JPanel grid, JButton[][] buttons){
|
||||
grid.removeAll();
|
||||
grid.repaint();
|
||||
for(int i = 0; i<buttons.length; i++){
|
||||
for(int j = 0; j<buttons.length;j++){
|
||||
JButton b0 = buttons[i][j];
|
||||
grid.add(b0);
|
||||
grid.repaint();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue