Singh M.
Posts: 154
Nickname: ms
Registered: Mar, 2002
|
|
Re: Getting Text from JTExtPane
|
Posted: Oct 1, 2002 10:14 PM
|
|
It is possible to ask every character abaout his Element?
Yes it is possible to do that. Let us take an example of an editor for working with java files. If the syntax highlighting is functional, and you want to check whether a given offset is a part of a method name, then you can do it as follows....
private boolean isMethodNamePart(int offs) throws BadLocationException{
Element element = this.getCharacterElement(offs);
AttributeSet attributes = element.getAttributes();
if (attributes.containsAttributes(attributeToCheck)){
return true;
}
return false;
}
This demonstrates that you can ask every character about its properties. This eg. assumes that your class extends DefaultStyledDocument. Just do some search, you will find something for JTextPane too.
|
|