aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes How to get the char index under the mouse cursor in a JTextComponent? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to get the char index under the mouse cursor in a JTextComponent?" Watch "How to get the char index under the mouse cursor in a JTextComponent?" New topic
Author

How to get the char index under the mouse cursor in a JTextComponent?

Jeronimo Backes
Greenhorn

Joined: Sep 20, 2004
Posts: 29
Hi! I created an editor where the user is able to put some properties in the text.

Some portions of text have some properties, some don't. I wish to display the available text properties when the mouse cursor hovers over the text. To to that, I need to know what is the char index under the mouse cursor.

How can I do that?


The art of being crazy is to NEVER commit the crazyness of being normal.
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
The (superclass) JTextComponent has two handy methods: viewToModel and modelToView.
Jeronimo Backes
Greenhorn

Joined: Sep 20, 2004
Posts: 29
Thanks! It works like a charm.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to get the char index under the mouse cursor in a JTextComponent?
 
Similar Threads
Mouse cursor location
magnifier cursor in java
Cursor position
what is the contrary event of "onFocus" ?
magnifier cursor in java