--------------------------------------------------------------------------------
How would i convert the following program into an applet?
Code:import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.io.*; import javax.swing.JOptionPane; public class minesweepGrid extends JFrame { private Bomb[] bmbArry = new Bomb[5]; private JButton[][] BombGrid = new JButton[5][5]; private static final int WIDTH = 200; private static final int HEIGHT = 200; private BombHandler00 bbHandler00; private BombHandler01 bbHandler01; private BombHandler02 bbHandler02; private BombHandler03 bbHandler03; private BombHandler04 bbHandler04; public minesweepGrid() { for(int x=0; x<5; x++) for(int y=0; y<5; y++) BombGrid[x][y] = new JButton(""); bmbArry[0]=new Bomb(0,0); bbHandler00 = new BombHandler00(); BombGrid[0][0].addActionListener(bbHandler00); bbHandler01 = new BombHandler01(); BombGrid[0][1].addActionListener(bbHandler01); bbHandler02 = new BombHandler02(); BombGrid[0][2].addActionListener(bbHandler02); bbHandler03 = new BombHandler03(); BombGrid[0][3].addActionListener(bbHandler03); bbHandler04 = new BombHandler04(); BombGrid[0][4].addActionListener(bbHandler04); setTitle("Minesweep"); Container pane = getContentPane(); pane.setLayout(new GridLayout(1,5)); for(int x=0; x<5; x++) for(int y=0; y<5; y++) pane.add(BombGrid[x][y]); setSize(WIDTH,HEIGHT); setVisible(true); setDefaultCloseOperation(EXIT_ON_CLOSE); } private class BombHandler00 implements ActionListener { public void actionPerformed(ActionEvent e) { char x,y; boolean explode; explode = false; IsItABomb(0,0); } public boolean IsItABomb(int X, int Y) { for(int x=0;x<bmbArry.length;x++) { if((bmbArry[x].GetXpos() == X) && (bmbArry[x].GetYpos() == Y)) JOptionPane.showMessageDialog(null,"Sorry, you have hit a bomb...Game Over!"); return true; } return false; } } private class BombHandler01 implements ActionListener { public void actionPerformed(ActionEvent e) { char x,y; char[][] matrix = new char[5][5]; boolean explode; explode = false; IsItABomb(0,1); } public boolean IsItABomb(int X, int Y) { for(int x=0;x<bmbArry.length;x++) { if((bmbArry[x].GetXpos() == X) && (bmbArry[x].GetYpos() == Y)) JOptionPane.showMessageDialog(null,"Sorry, you have hit a bomb...Game Over!"); return true; } return false; } } private class BombHandler02 implements ActionListener { public void actionPerformed(ActionEvent e) { char x,y; boolean explode; explode = false; IsItABomb(0,2); } public boolean IsItABomb(int X, int Y) { for(int x=0;x<bmbArry.length;x++) { if((bmbArry[x].GetXpos() == X) && (bmbArry[x].GetYpos() == Y)) JOptionPane.showMessageDialog(null,"Sorry, you have hit a bomb...Game Over!"); return true; } return false; } } private class BombHandler03 implements ActionListener { public void actionPerformed(ActionEvent e) { char x,y; boolean explode; explode = false; IsItABomb(0,3); } public boolean IsItABomb(int X, int Y) { for(int x=0;x<bmbArry.length;x++) { if((bmbArry[x].GetXpos() == X) && (bmbArry[x].GetYpos() == Y)) JOptionPane.showMessageDialog(null,"Sorry, you have hit a bomb...Game Over!"); return true; } return false; } } private class BombHandler04 implements ActionListener { public void actionPerformed(ActionEvent e) { char x,y; boolean explode; explode = false; IsItABomb(0,4); } public boolean IsItABomb(int X, int Y) { for(int x=0;x<bmbArry.length;x++) { if((bmbArry[x].GetXpos() == X) && (bmbArry[x].GetYpos() == Y)) JOptionPane.showMessageDialog(null,"Sorry, you have hit a bomb...Game Over!"); return true; } return false; } } public static void main(String[] args) { minesweepGrid mineSweep = new minesweepGrid(); } }


Reply With Quote


Bookmarks