What is the Constant Value of the Underline font in Java ?
Font.BOLD bold font
Font.ITALIC italic font
What is the UNDERLINE font Constant ? I try all the available constants but it didn't work .
You can add underline and strikethrough text using the Chunk class, and its setUnderline() method. You use a negative underline value to get the line lower below the text, and a positive underline value to get the line to strike through the text.
All implementations of the Java Platform must support TrueType fonts; support for other font technologies is implementation dependent. Physical fonts may use names such as Helvetica, Palatino, HonMincho, or any number of other font names.
1. An underline is a section of text in a document where the words have a line running beneath them. For example, this text should be underlined. Underlined text is commonly used to help draw attention to text. Today, underlines are commonly used to represent a hyperlink on a web page.
Underline ~ Like bold and italics, underlining can also be used to place special emphasis on one or more words but this tends to have limited use on web pages since underlined text is also the default font style for hyperlinks.
Suppose you wanted a underlined and bolded Serif style font, size=12.
Map<TextAttribute, Integer> fontAttributes = new HashMap<TextAttribute, Integer>();
fontAttributes.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
Font boldUnderline = new Font("Serif",Font.BOLD, 12).deriveFont(fontAttributes);
If you don't want it bolded, use Font.PLAIN instead of Font.BOLD. Don't use the getAttributes() method of the Font class. It will give you a crazy wildcard parameterized type Map<TextAttribute,?>
, and you won't be able to invoke the put() method. Sometimes Java can be yucky like that. If you're interested in why, you can check out this site: http://www.angelikalanger.com/GenericsFAQ/FAQSections/ParameterizedTypes.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With