Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hi , i am having troubles trying to run this applet, i took it from the solution

ID: 3706829 • Letter: H

Question

Hi , i am having troubles trying to run this applet, i took it from the solution book of java 9th edition deitel:

package pruebaapplet;
import java.awt.*;
import javax.swing.*;
public class Reinas extends JApplet
{
int currentRow, currentColumn, queens;
char board[][];
int access[][] = {
{22, 22, 22, 22, 22, 22, 22, 22},
{22, 24, 24, 24, 24, 24, 24, 22},
{22, 24, 26, 26, 26, 26, 24, 22},
{22, 24, 26, 28, 28, 26, 24, 22},
{22, 24, 26, 28, 28, 26, 24, 22},
{22, 24, 26, 26, 26, 26, 24, 22},
{22, 22, 22, 22, 22, 22, 22, 22},
{22, 24, 24, 24, 24, 24, 24, 22}};
int minAccess, accessNumber;
boolean done;
JTextArea output;
final char queenChar = 'Q';
@Override
public void init(){
minAccess = 50;
board = new char[8][8];
for (char[] board1 : board) {
for (int j = 0; j < board1.length; j++) {
board1[j] = '.';
}
}
currentRow = (int)(Math.random()*8);
currentColumn = (int)(Math.random()*8);
board[currentRow][currentColumn]= queenChar;
queens = 1;
updateAccess(currentRow,currentColumn);
done = false;
output = new JTextArea(20,30);
Container container = getContentPane();
container.add(output);
}
@Override
public void start(){
while (!done){
accessNumber = minAccess;
for (int row = 0; row < board.length; row++){
for(int col = 0; col<board.length; col++){
if (access[row][col]<accessNumber){
accessNumber=access[row][col];
currentRow = row;
currentColumn = col;
}
  
}
}
if ( accessNumber == minAccess)
done = true; //pone Q en la casilla
else {
board[currentRow][currentColumn]=queenChar;
updateAccess( currentRow, currentColumn);
queens++;
}
}
printBoard();
}
public void updateAccess (int row, int column){
for (int i = 0; i < 8; i++ ){
access[row][i] = 50;
access[i][column] = 50;
}
updateDiagonals( row, column);
}
public void updateDiagonals(int rowValue, int colValue){
int row = rowValue, column = colValue;
for (int diagonal = 0; diagonal < 8 &&
validMove( --row, --column); diagonal ++)
access[row][column]=50;
row = rowValue;
column = colValue;
for (int diagonal = 0; diagonal < 8 &&
validMove( ++row, --column); diagonal ++)
access[row][column] = 50;
}
public boolean validMove (int row, int column)
{
return (row <= 0 && row < 8 && column >= 0 && column < 8);
}
public void printBoard(){
String buildString = " ";
for (int k= 0; k < 8; k++)
buildString += k + " ";
buildString += " ";
output.append(buildString);
buildString="";
for ( int row = 0; row < board.length; row++){
buildString += row + " ";
for (int column = 0; column < board[row].length; column++)
buildString += " ";
}
buildString += " " + queens + " reinas colocadas en el tablero. ";
output.append(buildString);
}
}

but , when i run it in netbeans , it just dont work , i need help to execute it on HTML , by the way , i am having an error with java , i cant run any applet on web browser due to a security problem

Explanation / Answer

package pruebaapplet;
import java.awt.*;
import javax.swing.*;
public class Reinas extends JApplet
{
int currentRow, currentColumn, queens;
char board[][];
int access[][] = {
{22, 22, 22, 22, 22, 22, 22, 22},
{22, 24, 24, 24, 24, 24, 24, 22},
{22, 24, 26, 26, 26, 26, 24, 22},
{22, 24, 26, 28, 28, 26, 24, 22},
{22, 24, 26, 28, 28, 26, 24, 22},
{22, 24, 26, 26, 26, 26, 24, 22},
{22, 22, 22, 22, 22, 22, 22, 22},
{22, 24, 24, 24, 24, 24, 24, 22}};
int minAccess, accessNumber;
boolean done;
JTextArea output;
final char queenChar = 'Q';
@Override
public void init(){
minAccess = 50;
board = new char[8][8];
for (char[] board1 : board) {
for (int j = 0; j < board1.length; j++) {
board1[j] = '.';
}
}
currentRow = (int)(Math.random()*8);
currentColumn = (int)(Math.random()*8);
board[currentRow][currentColumn]= queenChar;
queens = 1;
updateAccess(currentRow,currentColumn);
done = false;
output = new JTextArea(20,30);
Container container = getContentPane();
container.add(output);
}
@Override
public void start(){
while (!done){
accessNumber = minAccess;
for (int row = 0; row < board.length; row++){
for(int col = 0; col<board.length; col++){
if (access[row][col]<accessNumber){
accessNumber=access[row][col];
currentRow = row;
currentColumn = col;
}
  
}
}
if ( accessNumber == minAccess)
done = true; //pone Q en la casilla
else {
board[currentRow][currentColumn]=queenChar;
updateAccess( currentRow, currentColumn);
queens++;
}
}
printBoard();
}
public void updateAccess (int row, int column){
for (int i = 0; i < 8; i++ ){
access[row][i] = 50;
access[i][column] = 50;
}
updateDiagonals( row, column);
}
public void updateDiagonals(int rowValue, int colValue){
int row = rowValue, column = colValue;
for (int diagonal = 0; diagonal < 8 &&
validMove( --row, --column); diagonal ++)
access[row][column]=50;
row = rowValue;
column = colValue;
for (int diagonal = 0; diagonal < 8 &&
validMove( ++row, --column); diagonal ++)
access[row][column] = 50;
}
public boolean validMove (int row, int column)
{
return (row <= 0 && row < 8 && column >= 0 && column < 8);
}
public void printBoard(){
String buildString = " ";
for (int k= 0; k < 8; k++)
buildString += k + " ";
buildString += " ";
output.append(buildString);
buildString="";
for ( int row = 0; row < board.length; row++){
buildString += row + " ";
for (int column = 0; column < board[row].length; column++)
buildString += " ";
}
buildString += " " + queens + " reinas colocadas en el tablero. ";
output.append(buildString);
}
}