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

  • Home
  • SEARCH
  • 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 6859365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:16:26+00:00 2026-05-27T02:16:26+00:00

I would like to convert my Simple Java program to an Applet Program. I’ve

  • 0

I would like to convert my Simple Java program to an Applet Program. I’ve looked for different tutorials but all were in general most of it didn’t talk about GUI to Applet.

This is my simple program if you could instruct me to do it or comment on the changed lines I would be so much appreciated.

Here is the code:

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class Test_Exam_091 {

    public static void main(String[] args) {
        new MyFrame();
    }
}

class MyFrame extends JFrame implements MouseListener {

    public MyFrame() {
        setTitle("Playing With The Mouse!");
        setSize(400, 400);
        setResizable(false);
        setVisible(true);
        addMouseListener(this);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        show();
    }

    public void mouseEntered(MouseEvent me) {
        System.out.println("Mouse entered at: ("
            + me.getX() + ", " + me.getY() + ")");
    }

    public void mouseExited(MouseEvent me) {
        System.out.println("Mouse exited at: ("
            + me.getX() + ", " + me.getY() + ")");
    }

    public void mouseClicked(MouseEvent me) {
        System.out.println("Mouse clicked at: ("
            + me.getX() + ", " + me.getY() + ")");
    }

    public void mousePressed(MouseEvent me) {
        System.out.println("Mouse pressed at: ("
            + me.getX() + ", " + me.getY() + ")");
    }

    public void mouseReleased(MouseEvent me) {
        System.out.println("Mouse released at: ("
            + me.getX() + ", " + me.getY() + ")");
    }
} // End of MyFrame class
  • 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-05-27T02:16:26+00:00Added an answer on May 27, 2026 at 2:16 am

    Some tips: Most of the lines of the constructor are irrelevant to applets.

    setTitle("Playing With The Mouse!"); // An applet has no title 
        // (Though it might have an ID/name in HTML)
    setSize(400, 400);  // Set in HTML
    setResizable(false); // An applet is usually fixed size
    setVisible(true); // Not relevant to an applet (visible by default)
    addMouseListener(this); 
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Not allowed in an applet
    show(); // Deprecated for components around 1.2, for TLCs around 1.5, ..
        // ..and redundant
    

    In the listener methods..

    System.out.println("Mouse pressed at: (" + me.getX() + ", " + me.getY() +")");
    

    Will cause problems, since that output will end up in the Java Console which is generally invisible to the end user (and most developers). It was not particularly appropriate to the JFrame form either. It will be necessary to add a JLabel or similar to the GUI, in which to display the results.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What would be a simple implementation of a method to convert a String like
I would like to be able to convert simple one digit time strings into
I have a somewhat simple query in SQL that I would like to convert
I would like to convert a string into a node. I have a method
I would like to convert tab to spaces in gVim. I added the following
I would like to convert the below foreach statement to a LINQ query that
I would like to convert from an image (like jpg or png) to PDF.
I would like to convert a yyyy-mm-dd to something like this: Saturday, 2 October
I would like to convert BufferedImage to an image that will display on JSP
I would like to convert this string foo_utf = u'nästy chäräctörs with å and

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.