|
@ -12,9 +12,13 @@ import java.awt.event.ActionEvent; |
|
|
import java.awt.event.ActionListener; |
|
|
import java.awt.event.ActionListener; |
|
|
import java.awt.event.MouseEvent; |
|
|
import java.awt.event.MouseEvent; |
|
|
import java.awt.event.MouseListener; |
|
|
import java.awt.event.MouseListener; |
|
|
|
|
|
import java.beans.PropertyChangeListener; |
|
|
|
|
|
import java.util.LinkedList; |
|
|
|
|
|
|
|
|
public class MainFrame extends JFrame { |
|
|
public class MainFrame extends JFrame { |
|
|
|
|
|
|
|
|
|
|
|
LinkedList<Model> history; |
|
|
|
|
|
|
|
|
private GameField gameField; |
|
|
private GameField gameField; |
|
|
|
|
|
|
|
|
private JSONArray currentGameDifficulty; |
|
|
private JSONArray currentGameDifficulty; |
|
@ -24,6 +28,8 @@ public class MainFrame extends JFrame { |
|
|
|
|
|
|
|
|
public void run() { |
|
|
public void run() { |
|
|
|
|
|
|
|
|
|
|
|
history = new LinkedList<>(); |
|
|
|
|
|
|
|
|
this.setLayout(null); |
|
|
this.setLayout(null); |
|
|
this.setVisible(true); |
|
|
this.setVisible(true); |
|
|
this.setBounds(300, 200, 500, 600); |
|
|
this.setBounds(300, 200, 500, 600); |
|
@ -115,9 +121,15 @@ public class MainFrame extends JFrame { |
|
|
JButton newButton = new JButton(); |
|
|
JButton newButton = new JButton(); |
|
|
newButton.setVisible(true); |
|
|
newButton.setVisible(true); |
|
|
newButton.setBounds(395, 5, 100, 25); |
|
|
newButton.setBounds(395, 5, 100, 25); |
|
|
newButton.setText("New"); |
|
|
|
|
|
|
|
|
newButton.setText("Vorwärts"); |
|
|
rootPanel.add(newButton); |
|
|
rootPanel.add(newButton); |
|
|
|
|
|
|
|
|
|
|
|
JButton backButton = new JButton(); |
|
|
|
|
|
backButton.setVisible(true); |
|
|
|
|
|
backButton.setBounds(10, 5, 100, 25); |
|
|
|
|
|
backButton.setText("Rückwärts"); |
|
|
|
|
|
rootPanel.add(backButton); |
|
|
|
|
|
|
|
|
JButton retryButton = new JButton(); |
|
|
JButton retryButton = new JButton(); |
|
|
retryButton.setVisible(true); |
|
|
retryButton.setVisible(true); |
|
|
retryButton.setText("Retry"); |
|
|
retryButton.setText("Retry"); |
|
@ -146,8 +158,8 @@ public class MainFrame extends JFrame { |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public void mousePressed(MouseEvent e) { |
|
|
public void mousePressed(MouseEvent e) { |
|
|
gameField.getActivePanel().setValue(Integer.valueOf(number)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gameField.getActivePanel().setValue(Integer.valueOf(number)); |
|
|
|
|
|
saveCurrentGameFieldStateToHistory(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
@ -171,9 +183,24 @@ public class MainFrame extends JFrame { |
|
|
numLabel1.setVisible(true); |
|
|
numLabel1.setVisible(true); |
|
|
jPanel.add(numLabel1); |
|
|
jPanel.add(numLabel1); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return jPanel; |
|
|
return jPanel; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void saveCurrentGameFieldStateToHistory() { |
|
|
|
|
|
Model model = new Model(gameField); |
|
|
|
|
|
history.add(model); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public LinkedList<Model> getHistory() { |
|
|
|
|
|
return history; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public GameField getGameField() { |
|
|
|
|
|
return gameField; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public JPanel setupJPanel() { |
|
|
public JPanel setupJPanel() { |
|
|
JPanel panel = new JPanel(); |
|
|
JPanel panel = new JPanel(); |
|
|
panel.setBounds(100, 450, 300, 30); |
|
|
panel.setBounds(100, 450, 300, 30); |
|
|