package de.htwg.minesweeper.aview.gui;

import javax.swing.*;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;


//import de.htwg.

public class GUI extends JFrame implements ActionListener{
	private static final long serialVersionUID = 1L;
	private JButton[][] buttonForTheMineSweeperFields;
	
	public GUI(String buttonStartStatus){
		//Sets layout in a grid, with 10x10 buttons, with a separtion between buttons at 2 pixels
		JFrame frame = new JFrame("Minesweeper");
		frame.setLayout(new GridLayout (10,10,2,2));
		buildGameField(frame, buttonStartStatus);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	    frame.setPreferredSize(new Dimension(550, 500));
	    frame.pack();
	    frame.setLocationRelativeTo(null);
	    frame.setVisible(true);
		
	}
	
	//sample main class, so this class can be run without running the entire game
	/*
	public static void main(String[] args){
		GUI start = new GUI("x");
		start.setJButtonText("h", 9, 9);
		System.out.println(start.getJButtonText(9, 9));
	}
	*/
	
	private void buildGameField(JFrame frame, String buttonStartStatus){
		buttonForTheMineSweeperFields = new JButton[10][10];
		
		//Should insert the userfield into each button
		for (int y=0; y < 10; y++){
			for (int x = 0; x < 10; x++){
				buttonForTheMineSweeperFields [x][y] = new JButton (buttonStartStatus);
				frame.add(buttonForTheMineSweeperFields[x][y]);
				buttonForTheMineSweeperFields [x][y].addActionListener(this);
			}
		}
	}
	
	public void setJButtonText(String text, int i, int j){
		buttonForTheMineSweeperFields[i][j].setText(text);
	}
	
	public String getJButtonText(int i, int j){
		return buttonForTheMineSweeperFields[i][j].getText();
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		
		//System.out.println(e.getSource());
		
	}

}

@@ -56,24 +56,67 @@
 swing.*;%0D%0A%0D%0A
+import de.htwg.minesweeper.model.Field;%0D%0A%0D%0A
 import java.
@@ -642,27 +642,8 @@
 rame
-, buttonStartStatus
 );%0D%0A
@@ -940,13 +940,8 @@
 me%0D%0A
-%09/*%0D%0A
 %09pub
@@ -960,44 +960,18 @@
 oid 
-main(String%5B%5D args)%7B%0D%0A%09%09GUI start = 
+run()%7B%0D%0A%09%09
 new 
@@ -979,110 +979,19 @@
 UI(%22
-x
 %22);%0D%0A%09%09
-start.setJButtonText(%22h%22, 9, 9);%0D%0A%09%09System.out.println(start.getJButtonText(9, 9));%0D%0A%09%7D%0D%0A%09*/%0D%0A
+%7D%0D%0A%09
 %09%0D%0A%09
@@ -1034,34 +1034,8 @@
 rame
-, String buttonStartStatus
 )%7B%0D%0A
@@ -1090,24 +1090,131 @@
 %5D%5B10%5D;%0D%0A%09%09%0D%0A
+%09%09String aa = Field.printField(Field.filledField).toString();%0D%0A%09%09String items %5B%5D = aa.split(%22 %22);%0D%0A%09%09%0D%0A%09%09%0D%0A
 %09%09//Should i
@@ -1227,12 +1227,8 @@
 the 
-user
 fiel
@@ -1368,33 +1368,29 @@
 Button (
-buttonStartStatus
+%22%22 + items%5Bx%5D
 );%0D%0A%09%09%09%09
@@ -1442,75 +1442,8 @@
 );%0D%0A
-%09%09%09%09buttonForTheMineSweeperFields %5Bx%5D%5By%5D.addActionListener(this);%0D%0A
 %09%09%09%7D

Update GUI.java