Solved

How to mouse click a JTextPane programatically..?

Posted on 2004-08-06
10
432 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…

756 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