Skip to content

Instantly share code, notes, and snippets.

@leapingbytes
Created October 4, 2013 21:13
Show Gist options
  • Save leapingbytes/6832881 to your computer and use it in GitHub Desktop.
Save leapingbytes/6832881 to your computer and use it in GitHub Desktop.
this seems to work. it reports reasonable attributes. for example for bold + italic: attributes : name : content attributes : font-style : italic attributes : color : #ffffff attributes : b : attributes : i : attributes : font-weight : bold attributes : font-family : Arial attributes : font : size=3 color=#ffffff face=Arial attributes : font-siz…
Caret cr = me.reachTextField.getCaret();
int position = cr.getDot()
Element e = me.reachTextField.getStyledDocument().getCharacterElement(position);
AttributeSet attributes = e.getAttributes();
Enumeration attributeNames = attributes.getAttributeNames();
while(attributeNames.hasMoreElements()) {
Object name = attributeNames.nextElement();
System.out.println("attributes : " + name + " : " + attributes.getAttribute(name));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment