Skip to content

Instantly share code, notes, and snippets.

@Sadin
Forked from Argygle/minesweeper
Last active February 26, 2016 02:53
Show Gist options
  • Save Sadin/b2098cf568e8e44d0380 to your computer and use it in GitHub Desktop.
Save Sadin/b2098cf568e8e44d0380 to your computer and use it in GitHub Desktop.
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
at Minesweeper.main(Minesweeper.java:14)
import java.util.Scanner;
import javax.swing.*;
import java.awt.GridLayout;
public class Minesweeper extends JFrame
{ JPanel board = new JPanel();
public static void main(String[] args)
{
}
public Minesweeper()
{
int a,b;
Scanner s = new Scanner(System.in);
System.out.println("Enter board dimensions:");
a = s.nextInt();
b = s.nextInt();
setSize(600,600);
setDefaultCloseOperation(EXIT_ON_CLOSE);
board.setLayout(new GridLayout(a,b));
int y,x = 0;
int counter = 0;
while(counter<a){
for(x)
}
}
}
@Argygle
Copy link

Argygle commented Feb 26, 2016

import java.util.Scanner;

import javax.swing.*;

public class Minesweeper
{
int a,b;
Scanner s = new Scanner(System.in);
System.out.println("Enter board dimensions");

JFrame frame = new JFrame("Minesweeper");
JButton reset = new JButton("Reset");
JButton[][] buttons = new JButton[a][b];
public static void main(String[] args)  
{

}

}

@Argygle
Copy link

Argygle commented Feb 26, 2016

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 title = "Dimensions";
    String query = "Enter Dimensions";
    String responsex = JOptionPane.showInputDialog(null,query,title,JOptionPane.QUESTION_MESSAGE);
    String responsey = JOptionPane.showInputDialog(null,query,title,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