Created
February 26, 2016 03:47
-
-
Save Argygle/7865855d0e87e366b869 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.awt.BorderLayout; | |
import java.awt.Container; | |
import java.awt.GridLayout; | |
import java.awt.event.ActionEvent; | |
import java.awt.event.ActionListener; | |
import javax.swing.*; | |
public class Minesweeper implements ActionListener | |
{ | |
int a,b; | |
String title1 = "Dimensions"; | |
String query1 = "Enter X Dimension"; | |
String response1 = JOptionPane.showInputDialog(null,query1,title1,JOptionPane.PLAIN_MESSAGE); | |
String title2 = "Dimensions"; | |
String query2 = "Enter Y Dimensions"; | |
String response2 = JOptionPane.showInputDialog(null,query2,title2,JOptionPane.PLAIN_MESSAGE); | |
{ | |
a = Integer.parseInt(response1); | |
b = Integer.parseInt(response2); | |
} | |
JFrame frame = new JFrame("Minesweeper"); | |
JButton reset = new JButton("Reset"); | |
JButton[][] buttons = new JButton[a][b]; | |
int[][] counts = new int[a][b]; | |
Container grid = new Container(); | |
public Minesweeper() | |
{ | |
frame.setSize(600, 600); | |
frame.setLayout(new BorderLayout()); | |
frame.add(reset,BorderLayout.NORTH); | |
reset.addActionListener(this); | |
grid.setLayout(new GridLayout(a,b)); | |
for(int x = 0; x <buttons.length; x++) | |
{ | |
for(int y = 0; y<buttons.length; y++) | |
{ | |
buttons[x][y] = new JButton(); | |
buttons[x][y].addActionListener(this); | |
grid.add(buttons[x][y]); | |
} | |
} | |
frame.add(grid,BorderLayout.CENTER); | |
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | |
frame.setVisible(true); | |
} | |
public static void main(String[] args) | |
{ | |
} | |
@Override | |
public void actionPerformed(ActionEvent arg0) { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment