Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7755347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:32:42+00:00 2026-06-01T12:32:42+00:00

This is my first applet project and for some reason when I try to

  • 0

This is my first applet project and for some reason when I try to run the applet I get this error.

Warning: Can't read AppletViewer properties file: 
    C:\Users\students\.hotjava\properties Using defaults.
java.security.AccessControlException: access denied (
    "java.lang.RuntimePermission" "exitVM.0")

But the code works perfect other than that. I am unsure what is causing this error. I am 2 days late on this assignment, and need someone to help me. I have been banging my head on the desk for hours.

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.Random;
import javax.swing.JApplet;


/** rock paper scissors class */
public class JRockPaperScissors extends JApplet{
    // Variables declaration
    private JLabel titleLbl;
private JLabel selectionLbl;
private JLabel resultsLbl;
private JTextArea resultTextArea;
private JButton rockBn;
private JButton paperBn;
private JButton scissorBn;
private Container contentPane;
    private int cpu = 0;
    private int wins = 0;
    private int loses = 0;
    private int ties = 0;
    private final int CHOICE_MAX = 3;
    private final int ROCK = 0;
    private final int PAPER = 1;
    private final int SCISSORS = 2;
    private Random rand = new Random();
// End of variables declaration

public JRockPaperScissors(){
    initializeComponent();
}

    /** initializing componets */
private void initializeComponent()
{
    titleLbl = new JLabel();
    selectionLbl = new JLabel();
    resultsLbl = new JLabel();
    resultTextArea = new JTextArea();
    rockBn = new JButton();
    paperBn = new JButton();
    scissorBn = new JButton();
    contentPane = getContentPane();

    //
    // titleLbl
    //
    titleLbl.setText("Rock, Paper, Scissors");
            titleLbl.setFont(new Font("Garrmond", Font.BOLD, 30));
    //
    // selectionLbl
    //
    selectionLbl.setText("Choose one");
            selectionLbl.setFont(new Font("Arial",Font.BOLD,14));
    //
    // resultsLbl
    //
    resultsLbl.setText("*****Results*****");
            selectionLbl.setFont(new Font("Arial",Font.BOLD,14));
    //
    // resultTextArea
    //
    resultTextArea.setOpaque(false);
    resultTextArea.setBackground(new Color(236, 233, 216));

    //
    // rockBn
    //
    rockBn.setText("Rock");
    rockBn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e)
        {
            rockBn_actionPerformed(e);
        }

    });
    //
    // paperBn
    //
    paperBn.setText("Paper");
    paperBn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e)
        {
            paperBn_actionPerformed(e);
        }

    });
    //
    // scissorBn
    //
    scissorBn.setText("Scissors");               
    scissorBn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e)
        {
            scissorBn_actionPerformed(e);
        }

    });
    //
    // contentPane
    //
    contentPane.setLayout(null);
    addComponent(contentPane, titleLbl, 5,9,370,47);
    addComponent(contentPane, selectionLbl, 9,54,150,35);
    addComponent(contentPane, resultsLbl, 9,93,144,38);
    addComponent(contentPane, resultTextArea, 5,132,398,111);
    addComponent(contentPane, rockBn, 162,58,78,31);
    addComponent(contentPane, paperBn, 247,58,81,31);
    addComponent(contentPane, scissorBn, 334,58,87,31);
    contentPane.setSize(new Dimension(435, 290));
    //
    // JRockPaperScissors
    //      
    setTitle("Paper Rock Scissors");
    setSize(435, 290);
    setVisible(true);
}

/** Add Component Without a Layout Manager (Absolute Positioning) */
private void addComponent(Container container,Component c,int x,int y,int width,int height)
{
    c.setBounds(x,y,width,height);
    container.add(c);
}

/** action event methods */
private void rockBn_actionPerformed(ActionEvent e)
{
        //play the game choosing rock
        play(ROCK);
}

private void paperBn_actionPerformed(ActionEvent e)
{
        //play the game choosing paper
        play(PAPER);
}

private void scissorBn_actionPerformed(ActionEvent e)
{
        //play the game choosing scissors
        play(SCISSORS);
}
    //method to play the game
    private void play(int pick){
         String resultStr = "";                   
         //random computer choice
         cpu = rand.nextInt(CHOICE_MAX);
         //nested if statments to determine winner loser or tie
         if(pick == cpu){
             ties++;
             resultStr = "You picked " + selection(pick) + " ---- Computer picked " + selection(cpu);
             resultStr += "\nWinner: Tie";
             resultStr += "\nYou: " + Integer.toString(wins) + "  " + "Computer: " + Integer.toString(loses) + " Ties: " + Integer.toString(ties);
             resultTextArea.setText(resultStr);
         }
         else if( (pick == ROCK) && (cpu == SCISSORS) ){
             wins++;
             resultStr = "You picked " + selection(pick) + " ---- Computer picked " + selection(cpu);
             resultStr += "\nWinner: You";
             resultStr += "\nYou: " + Integer.toString(wins) + "  " + "Computer: " + Integer.toString(loses) + " Ties: " + Integer.toString(ties);
             resultTextArea.setText(resultStr);
         }
         else if( (pick == PAPER) && (cpu == ROCK) ){
             wins++;
             resultStr = "You picked " + selection(pick) + " ---- Computer picked " + selection(cpu);
             resultStr += "\nWinner: You";
             resultStr += "\nYou: " + Integer.toString(wins) + "  " + "Computer: " + Integer.toString(loses) + " Ties: " + Integer.toString(ties);
             resultTextArea.setText(resultStr);                 
         }
         else if( (pick == SCISSORS) && (cpu == PAPER) ){
             wins++;
             resultStr = "You picked " + selection(pick) + " ---- Computer picked " + selection(cpu);
             resultStr += "\nWinner: You";
             resultStr += "\nYou: " + Integer.toString(wins) + "  " + "Computer: " + Integer.toString(loses) + " Ties: " + Integer.toString(ties);
             resultTextArea.setText(resultStr);
         }
         else{
             loses++;
             resultStr = "You picked " + selection(pick) + " ---- Computer picked " + selection(cpu);
             resultStr += "\nWinner: Computer";
             resultStr += "\nYou: " + Integer.toString(wins) + "  " + "Computer: " + Integer.toString(loses) + " Ties: " + Integer.toString(ties);
             resultTextArea.setText(resultStr);                 
         }

    }
        //function returns paper rock or scissors as a string
         public String selection(int choice){
             String tempStr;
             switch(choice){
               case 0:
                     tempStr = "rock";
                     break;
               case 1:
                     tempStr = "paper";
                     break;
               case 2:
                     tempStr = "scissors";
                     break;
               default:
                     tempStr = "invalid";
              }
              return tempStr;
         }

}

HTML CODE

<html>
<head><title>Rock Paper Scissors</title></head>
<body bgcolor="black">
<font color="yellow"><center><h1>Welcome!! Ready to play?</h1></center>
<p><b><object code = “JRockPaperScissors.class” width = “435” height = “290”></object>
</font>
</body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T12:32:44+00:00Added an answer on June 1, 2026 at 12:32 pm

    This appears to be a broken applet viewer installation to me. That code runs without error in applet viewer here (after I comment the line that does not compile, which implies that source is not what you are using). What happens when you try it in a Java enabled browser?

    HTML

    I don’t think the HTML is relevant to the problem, but since you mentioned it:

    <object code = “JRockPaperScissors.class” width = “435” height = “290”></object>
    

    I have 3 recommendations during testing.

    1. Swap object for applet
    2. Remove the .class extension of the code attribute – it is meant to be the fully qualified class name, not a file name. While the 2nd is usually tolerated, the 1st is correct.
    3. Change the ‘smart quotes’ for standard " style quotes. It looks like that HTML was prepared in a word processor. Or better still, remove the quotes completely.

    E.G.

     <applet code=JRockPaperScissors width=435 height=290></applet>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my first project in Java. I'm creating batch FTP video uploader applet
This is for an upcoming project. I have two tables - first one keeps
Warning: This is my first IPhone Application and I'm new to Objective C, therefore
This is my second try to solve this problem. My first try was here
This first bit works: $my_id = 617; $post_id_7 = get_post($my_id); $title = $post_id_7->post_excerpt; echo
i have two arrays like this first array Array ( [0228] => Array (
Saw this piece of code in a Ruby on Rails book. This first one
problem euler #5 i found the solution but i don't know why this first
Using Dozer to map two objects, I have: /** /* This first class uses
#include <iostream> using namespace std; // This first class contains a vector and a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.