Skip to content

Instantly share code, notes, and snippets.

@Argygle
Created February 26, 2016 03:06
Show Gist options
  • Save Argygle/fcbb1782cf615fe9bb69 to your computer and use it in GitHub Desktop.
Save Argygle/fcbb1782cf615fe9bb69 to your computer and use it in GitHub Desktop.
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Dialog;
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;
a = Integer.parseInt(responsex);
b = Integer.parseInt(responsey);
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)
{
String titlex = "Dimensions";
String queryx = "Enter X Dimension";
String responsex = JOptionPane.showInputDialog(null,queryx,titlex,JOptionPane.QUESTION_MESSAGE);
String titley = "Dimensions";
String queryy = "Enter Y Dimensions";
String responsey = JOptionPane.showInputDialog(null,queryy,titley,JOptionPane.QUESTION_MESSAGE);
}
@Override
public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub
}
}
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
at Minesweeper.main(Minesweeper.java:45)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment