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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:18:14+00:00 2026-06-05T21:18:14+00:00

I am running an applet, and am trying to focus on a component outside

  • 0

I am running an applet, and am trying to focus on a component outside of the init method. I have tried using requestFocus and requestFocusInWindow. Both of these return true, as do isDisplayable, isVisible, and isFocusable, but calling hasFocus right after this returns false. The component just doesn’t show up in the applet.

Here is the method called by the event listener (when the user clicks ‘begin battle’), trying to focus on the component:

private void beginBattle(){
    BattleSequence bs = new BattleSequence(..);
    remove(pnlInit);
    remove(pnlOOB);
    remove(pnlBattle);
    add(bs);
    bs.setVisible(true);
    bs.requestFocusInWindow(); //this returns 'true'
    bs.setBounds(0, 0, bs.getSize().width, bs.getSize().height);
    bs.init();
    }

public class BattleSequence extends RavelSequence

public abstract class RavelSequence extends Applet implements KeyListener, FocusListener

Why is the focus request denied? If there is more code that is relevant, I can post it!

***EDIT:
Adding the mouse listener worked to get focus to the component, but I don’t want to have the user need a mouse to control the game. I changed the declaration of RavelSequence to extend Container instead of Applet, and everything works peachy.
bs.hasFocus still returns false, but the key events are handled appropriately.

  • 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-05T21:18:16+00:00Added an answer on June 5, 2026 at 9:18 pm

    Try to call it on event dispatch thread.

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

Sidebar

Related Questions

I have an applet running in a browser tab. When I switch to a
in our application we have a Java applet running inside a .NET browser control.
I'm using a java based uploading construct http://www.javaatwork.com/java-upload-applet/details.html that I tried running over night.
I'm trying to isolate duplicates in a 500MB database and have tried two ways
I'm trying to connect from a standalone applet to a servlet running on tomcat:
I'm trying to sign a java applet using an spc file from godaddy. Here's
I'm trying to install pyobjc (using pyobjc-1.2-python2.3-macosx10.2.dmg) on a Mac running OSX 10.6 and
I'm trying to run R using Java. I have R installed on my Mac
I'm running Mac OS X 10.5.8 and have been trying over the past couple
I'm running a little applet game in the appletviewer, and I have another java

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.