Set keyboard focus to Applet when it is loaded



hi,

I have an applet with a JTextArea and I would like the keyboard focus
to be in that JTextArea as soon as the applet is loaded (so that
the user can immediately start typing).

Currently I do two things (with no success):

1. use javascript to set the focus on the <applet> element:
<body onLoad="document.getElementById('kbapplet').focus()">
....
<applet id="kbapplet" code=".."></applet>

2. call requestFocus() and textarea.requestFocusInWindow()
in the init() method (as well as in windowOpened-handler etc).

thanks in advance!

--
Felix Natter
.



Relevant Pages

  • Re: What JVMs on which OSs ?
    ... just as a Windows application which it more closely resembles. ... The live applet as well as the demo applets launch from a link ... keyboard focus and a mouse click in, say a text box, won't ... On the live applet my applet's request for another html page ...
    (comp.lang.java.programmer)
  • Re: No keyboard into in JApplet
    ... Not a real solution, but I noticed that I could get ... the keyboard focus in a text component by clicking next to it, ... Here is a test applet on the web that has a Textarea: ... They can accept key input. ...
    (comp.lang.java.gui)
  • Re: Set keyboard focus to Applet when it is loaded
    ... I have an applet with a JTextArea and I would like the keyboard focus to ... Felix Natter ...
    (comp.lang.java.gui)
  • Re: Set keyboard focus to Applet when it is loaded
    ... I have an applet with a JTextArea and I would like the keyboard focus ... add it to a timer, setRepeats, 150ms should do ...
    (comp.lang.java.gui)
  • JScrollPane in an applet
    ... an applet vs. an application? ... JScrollPane and it doesn't seem to show the scroll bar no matter what. ... I've tried setting the scroll bar policy, resizing the applet within the ... HTML, resizing the JScrollPane, resizing the JTextArea, resizing browser ...
    (comp.lang.java.programmer)