Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to mouse click a JTextPane programatically..?

Posted on 2004-08-06
10
Medium Priority
?
442 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 500 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

670 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