Powered by Ajaxy
Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

Java: Example of an underline and strikethrough text

Java: Example of an underline and strikethrough text

  import java.awt.*;
  import java.awt.font.TextAttribute;
  import java.text.*;
  import javax.swing.*;
  public class AttributText
		 public static void main(String[] args)
		   JFrame f = new JFrame("Strikethrough text")
				public void paint(Graphics g)
				Graphics2D g2 = (Graphics2D)g;
				String texte = "Exemples Java et Python";
				Dimension d = getSize();
				// Create a font
				Font font = new Font("Times New Roman", Font.PLAIN, 24);
				AttributedString str_attribut = new AttributedString(texte);
				// Apply the font to the text
				str_attribut.addAttribute(TextAttribute.FONT, font);
				// Undeline the text
				str_attribut.addAttribute(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON, 0, 8);
				// strikethrough text
				str_attribut.addAttribute(TextAttribute.STRIKETHROUGH, TextAttribute.STRIKETHROUGH_ON,
											 17, texte.length());
				g2.drawString(str_attribut.getIterator(), 40, 80);

Users who found this page were searching for:

  • how to underline a java label using html tags
  • java.awt.font.textattribute underline example
  • how to set strikethrough label in bb java
  • create+UnderLine+using+Font+in+java+swing
  • how+to+use+strikethrough+swing
  • java jlabel underline text
  • how to set the underline font of text on jlabel in java
  • how to display strike characters in java + strikethrough on example
  • how to print strikethroughs in java
  • java method strikethrough

No comments yet.

Leave a Comment