sterrius
asked on
How to mouse click a JTextPane programatically..?
Hi,
I'm trying to set the focus to a JTextPane after another user event occurs (clicking a menu option for example) so that the caret is active in the Pane.
Any help greatly appreciated, thanks...
Sterry.
I'm trying to set the focus to a JTextPane after another user event occurs (clicking a menu option for example) so that the caret is active in the Pane.
Any help greatly appreciated, thanks...
Sterry.
pane.requestFocus()
Use a method called requestFocus(); in every event you handle declare it to set the focus to JTextPane.
Example :
JTextPane x = new JTextPane();
x.requestFocus();
Hope that helps . . .
Javatm
Example :
JTextPane x = new JTextPane();
x.requestFocus();
Hope that helps . . .
Javatm
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
requestFocus() is not recomended, from the javadoc:
"Because the focus behavior of this method is platform-dependent, developers are strongly encouraged to use requestFocusInWindow when possible."
"Because the focus behavior of this method is platform-dependent, developers are strongly encouraged to use requestFocusInWindow when possible."