This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Determining whether object at current caret position is plain text or a component Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Determining whether object at current caret position is plain text or a component" Watch "Determining whether object at current caret position is plain text or a component" New topic
Author

Determining whether object at current caret position is plain text or a component

Richard Robbins
Ranch Hand

Joined: Mar 07, 2001
Posts: 66
How does one determine whether there is regular text or a component at the current caret position in a JTextPane? For instance..
JTextPane textInput = new JTextPane();
.
.
for(int i = 0; i < textInput.getText().length(); i++){
textInput.setCaretPosition(i);
//check to see whether the current caret position contains
//regular text (content) or if it contains a component.
}


Richard Robbins is one of the founders of WebsiteTemplateDatabase.com, a resource for free website templates and Photoshop tutorials. He also consults for an online boutique selling baptism dresses and christening gowns.
 
Don't get me started about those stupid light bulbs.
 
subject: Determining whether object at current caret position is plain text or a component
 
Similar Threads
Counting Lines
JTextPane
Displaying line # with JTextArea
Find index by xy ??
how to get column position and row position from jtextarea