aspose file tools
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 Head First Android 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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Determining whether object at current caret position is plain text or a component
 
It's not a secret anymore!