Reputation: 764
I am developing an IDE
for which I need a help. Suppose you have inserted a JLabel
(with a text) in the container. Now, how do I check whether the text of the JLabel
is underlined, strikedthrough and sub-(or super-)scripted?
We know that for checking for Bold and Italic styles, we have the isBold()
and isItalic()
methods of the Font
class. How can we do the same for UNDERLINE
, STRIKETHROUGH
, SUPERSCRIPT
and SUBSCRIPT
?
Upvotes: 2
Views: 584
Reputation: 32980
If you used java.awt.font.TextAttribute
to achieve the styling you can check with
Map attributes = font.getAttributes();
boolean underlined = attributes.containsKey(TextAttribute.UNDERLINE);
Upvotes: 3