Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

need java program for minesweeper

+4 votes
asked Dec 3, 2019 by Manav

1 Answer

0 votes
answered Mar 15, 2025 by abhiram rangavajhala (810 points)
import javax.swing.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.net.URL;

public class bombButton extends JButton implements ActionListener {
ImageIcon Bomb,zero,one,two,three,four,five,six,seven,eight;

public bombButton(){
    URL imageBomb = getClass().getResource("Bomb.png");
    Bomb= new ImageIcon(imageBomb);

    URL imageZero = getClass().getResource("0.jpg");
    zero= new ImageIcon(imageZero);

    URL imageOne = getClass().getResource("1.jpg");
    one= new ImageIcon(imageOne);

    URL imageTwo = getClass().getResource("2.jpg");
    two= new ImageIcon(imageTwo);

    URL imageThree = getClass().getResource("3.jpg");
    three= new ImageIcon(imageThree);

    URL imageFour = getClass().getResource("4.jpg");
    four= new ImageIcon(imageFour);

    URL imageFive = getClass().getResource("5.jpg");
    five= new ImageIcon(imageFive);

    URL imageSix = getClass().getResource("6.jpg");
    six= new ImageIcon(imageSix);

    URL imageSeven = getClass().getResource("7.jpg");
    seven= new ImageIcon(imageSeven);

    URL imageEight = getClass().getResource("8.jpg");
    eight= new ImageIcon(imageEight);

    this.addActionListener(this);
}

public void actionPerformed(ActionEvent e){
    switch(){
        case 0:
            setIcon(null);
            break;
        case 1:
            setIcon(Bomb);
            break;
        case 2:
            setIcon(one);
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and receive answers from other members of the community.
...