Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the Constant Value of the Underline font in Java?

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 .

like image 732
Waseem Avatar asked Nov 28 '08 14:11

Waseem


People also ask

How do you underline a font in Java?

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.

What is the font used in Java?

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.

What is a underline text?

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.

Is underline a font?

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.


1 Answers

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

like image 93
Blake Avatar answered Sep 22 '22 03:09

Blake