Forum Stats

  • 3,769,805 Users
  • 2,253,023 Discussions
  • 7,875,211 Comments

Discussions

Applet does not get default focus

843807
843807 Member Posts: 46,582
edited Sep 26, 2002 4:10AM in Java Desktop Applications
I open my Applet which has a menu and other stuff in IE browser.
However I cannot access the applet menu using keyboard.
Could someone let me know how to retain the applet focus for my application.

Comments

  • 843807
    843807 Member Posts: 46,582
    Use the requestFocus() method of any component to get focus for your applet.

    The key listener seems a bit funny in WinXP. I wrote an applet that worked fine in other versions of windows but the keylistener refused to work in WinXP. I haven't worked out what the problem is yet.
  • 843807
    843807 Member Posts: 46,582
    Try making it a FocusCycleRoot

    getApplet().setFocusCycleRoot(true);
    getApplet().setFocusTraversalPolicy(new LayoutFocusTraversalPolicy());

    Replace getApplet() with your applet of course.
This discussion has been closed.