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 6547945
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:53:30+00:00 2026-05-25T11:53:30+00:00

I’m trying to make a console for a java game, in an applet. The

  • 0

I’m trying to make a console for a java game, in an applet. The console is an independant Frame with a TextArea, used to show loading/downloading progression.
I’m running into some problems when I try to hide the console on closing.

Here is the simplified code :

//Method inherited from the Applet class
public void init() {
    console = new Frame();
    console.setSize(500, 300);
    console.addWindowListener(new WindowAdapter(){
        public void windowClosing(WindowEvent e) {
            console.setVisible(false);
        }
    });

    consoleText = new TextArea();
    consoleText.setSize(500, 300);

    console.add(consoleText);

    console.setVisible(true);

    gameThread = new Thread() {
        public void run() {
            mainLoop();
        }
    };
    gameThread.start();
}

The thread “gameThread” simply hang when I close the Frame “console”. Even when I replace “console.setVisible(false);” with “console.setExtendedState(Frame.ICONIFIED);”, the thread still hang without any warning.
While running the applet in a browser, I have to kill the process in the task manager. Very annoying.

Using a JFrame instead does the exact same thing, except the bug is harder to reproduce.

I just want the user to be able to get rid of the console.

Does anybody have an idea ? Thanks !

  • 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-25T11:53:31+00:00Added an answer on May 25, 2026 at 11:53 am

    I think that you shouldn’t be using a Frame/JFrame for this but rather a JDialog, since the window is behaving as a dialog. Also be sure that you’re using a JApplet rather than an Applet.

    Edit
    Note that I cannot reproduce your problem based on your displayed code snippet. Consider creating and posting an SSCCE that would show us the problem directly.

    Edit 2
    My SSCCE that does not reproduce your problem:

    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    
    public class AppletEg extends JApplet {
       private static final int MAX_LOOP = 30;
       private static final long SLEEP_TIME = 500;
       private JFrame console;
       private JTextArea consoleText;
       private Thread gameThread;
    
       @Override
       public void init() {
          console = new JFrame();
          console.setSize(500, 300);
          console.addWindowListener(new WindowAdapter() {
             public void windowClosing(WindowEvent e) {
                console.setVisible(false);
             }
          });
    
          consoleText = new JTextArea();
          consoleText.setPreferredSize(new Dimension(500, 300));
    
          console.add(new JScrollPane(consoleText));
    
          console.setVisible(true);
    
          gameThread = new Thread() {
             public void run() {
                mainLoop();
             }
          };
          gameThread.start();
       }
    
       private void mainLoop() {
          for (int i = 0; i < MAX_LOOP; i++) {
             System.out.println("I: " + i);
             try {
                Thread.sleep(SLEEP_TIME);
             } catch (InterruptedException e) {
             }
          }
       }
    }
    

    Edit 3
    My SSCCE using a JDialog:

    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    
    public class AppletEg extends JApplet {
       private static final int MAX_LOOP = 30;
       private static final long SLEEP_TIME = 500;
       private JDialog console;
       private JTextArea consoleText;
       private Thread gameThread;
    
       @Override
       public void init() {
          Window win = SwingUtilities.getWindowAncestor(this);
          console = new JDialog(win);
          consoleText = new JTextArea();
          consoleText.setPreferredSize(new Dimension(500, 300));
    
          console.add(new JScrollPane(consoleText));
          console.pack();
          console.setLocationByPlatform(true);
          console.setVisible(true);
    
          gameThread = new Thread() {
             public void run() {
                mainLoop();
             }
          };
          gameThread.start();
       }
    
       private void mainLoop() {
          for (int i = 0; i < MAX_LOOP; i++) {
             System.out.println("i: " + i);
             try {
                Thread.sleep(SLEEP_TIME);
             } catch (InterruptedException e) {
             }
          }
       }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I used javascript for loading a picture on my website depending on which small
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I want to construct a data frame in an Rcpp function, but when I
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm trying to create an if statement in PHP that prevents a single post
I have thousands of HTML files to process using Groovy/Java and I need to

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.