Solved

How to mouse click a JTextPane programatically..?

Posted on 2004-08-06
10
425 Views
Last Modified: 2011-10-03
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.
0
Comment
Question by:sterrius
  • 2
10 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 11739612
pane.requestFocus()
0
 
LVL 15

Expert Comment

by:Javatm
ID: 11739618
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
0
 
LVL 92

Accepted Solution

by:
objects earned 125 total points
ID: 11741072
textpane.requestFocusInWindow();
0
 
LVL 92

Expert Comment

by:objects
ID: 11937630
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."
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question