2

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?

RockAndRoll
  • 2,247
  • 2
  • 16
  • 35
RisingHerc
  • 694
  • 1
  • 9
  • 26

1 Answers1

3

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);
wero
  • 32,544
  • 3
  • 59
  • 84