Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

grabFocus after JOptionPane in apple?

Status
Not open for further replies.

epimorphic

Programmer
Jul 20, 2001
1
US
I have an applet that contains a JScrollPane (which in turn contains a JTextPane).

A button in the applet launches a JOptionPane that asks for some information from the user, which is then incorporated into the Document for the JTextPane.

The problem I'm having is this: I want the JTextPane to regain the focus after the JOptionPane has done its thing. I cannot seem to make this happen. Instead, once the JOptionPane window is closed, the focus is on the browser window containing the applet., and not the applet itself. (E.g., when I press the up/down arrow keys, they move the browser window rather than the cursor inside the JTextPane, although the cursor is visible and blinking.)

I have tried several variations on grabFocus() and requestFocus(), so far to no avail. Any help would be greatly appreciated.

--
Michael Dickson
epimorphic, incorporated
 
For a workaround, you could create your own JFrame that implements the JOptionPane's functionality (containing a JTextField and a JButton or two) and passes the focus back in a WindowListener's WindowClosing function. I don't know the JOptionPane's implementation all too well - I don't think you passed a null value as the input message's owner, did you?
allow thyself to be the spark that lights the fire
haslo@haslo.ch - www.haslo.ch​
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top