'Strike through java.awt.Font

Is there a way to make a java.awt.Font strike through?



Solution 1:[1]

underline and strikethrough examples in awt.

http://www.java2s.com/Code/Java/2D-Graphics-GUI/TextAttributeUnderlineandstrikethrough.htm

Basically, create a new AttributedString out of your string, add a STRIKETHROUGH attribute, and draw.

NOTE: This will NOT make the FONT strikethrough, but you can set the text to that font and then strikethrough on the text. This is simply another way of doing it. Rich's answer actually makes the font strikethrough.

Solution 2:[2]

In case you are interested in what other text attributes are available you can use the Visual Font Designer to experiment with different attributes to see how they look. The designer also allows you to change the Font so you can verify if the strike through is available for the Font you want to use.

Solution 3:[3]

Use this

yourTextView.setPaintFlags(holder.name.getPaintFlags() |
Paint.STRIKE_THRU_TEXT_FLAG);

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 camickr
Solution 3 nandini Srivastava