Solved

How to mouse click a JTextPane programatically..?

Posted on 2004-08-06
10
419 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
thymeleaf natural templating vs JSP 2 98
session migration servlets 2 36
web services creation SOAP vs REST 5 40
Oracle SQL syntax check  without executing 6 54
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
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 theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

773 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