|
|
@ -1,5 +1,10 @@ |
|
|
|
package src; |
|
|
|
|
|
|
|
import org.json.simple.JSONArray; |
|
|
|
import org.json.simple.JSONObject; |
|
|
|
import org.json.simple.parser.JSONParser; |
|
|
|
import org.json.simple.parser.ParseException; |
|
|
|
|
|
|
|
import javax.swing.*; |
|
|
|
import javax.swing.border.LineBorder; |
|
|
|
import java.awt.*; |
|
|
@ -12,6 +17,9 @@ public class MainFrame extends JFrame { |
|
|
|
|
|
|
|
private GameField gameField; |
|
|
|
|
|
|
|
private JSONArray currentGameDifficulty; |
|
|
|
private Model currentModel; |
|
|
|
|
|
|
|
public void run() { |
|
|
|
|
|
|
|
this.setLayout(null); |
|
|
@ -36,7 +44,6 @@ public class MainFrame extends JFrame { |
|
|
|
gameField.setBounds(70, 50, 360, 360); |
|
|
|
rootPanel.add(gameField); |
|
|
|
|
|
|
|
|
|
|
|
int j = 0; |
|
|
|
|
|
|
|
JPanel boxPanel = setupJPanel(); |
|
|
@ -138,7 +145,6 @@ public class MainFrame extends JFrame { |
|
|
|
return jPanel; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public JPanel setupJPanel() { |
|
|
|
JPanel panel = new JPanel(); |
|
|
|
panel.setBounds(100, 450, 300, 30); |
|
|
@ -173,6 +179,10 @@ public class MainFrame extends JFrame { |
|
|
|
return jPanel; |
|
|
|
} |
|
|
|
|
|
|
|
private void loadDataToGameField(JSONObject jsonObject) { |
|
|
|
currentModel = new Model(jsonObject, gameField); |
|
|
|
} |
|
|
|
|
|
|
|
private JMenuBar setupMenuBar() { |
|
|
|
|
|
|
|
JMenuBar menu_mb=new JMenuBar(); |
|
|
@ -184,6 +194,21 @@ public class MainFrame extends JFrame { |
|
|
|
JMenuItem menu_i1=new JMenuItem("Nochmal"); |
|
|
|
JMenuItem menu_i2=new JMenuItem("Tipp"); |
|
|
|
JMenuItem menu_i4=new JMenuItem("Einfach"); |
|
|
|
menu_i4.addActionListener(new ActionListener() { |
|
|
|
@Override |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
String data = Model.loadAllData(); |
|
|
|
JSONObject object = null; |
|
|
|
try { |
|
|
|
object = (JSONObject)new JSONParser().parse(data); |
|
|
|
} catch (ParseException ex) { |
|
|
|
throw new RuntimeException(ex); |
|
|
|
} |
|
|
|
currentGameDifficulty = (JSONArray) object.get("easyGame"); |
|
|
|
loadDataToGameField((JSONObject) currentGameDifficulty.get(0)); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
JMenuItem menu_i5=new JMenuItem("Mittel"); |
|
|
|
JMenuItem menu_i6=new JMenuItem("Schwer"); |
|
|
|
|
|
|
|