Strike through java.awt.Font

后端 未结 3 1698
Happy的楠姐
Happy的楠姐 2021-02-12 16:46

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

3条回答
  •  旧时难觅i
    2021-02-12 17:19

    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.

提交回复
热议问题