Superscript in Java string
•
Java
Does Java string support superscripts in strings? If so, then how to use it, I have searched web pages and APIs, but I can't figure out how I use it for my purposes
Although this will be printed on the web page, I can't use HTML tags here, any suggestions please
Solution
View Java text. Attributedstring, which supports subscripts and so on For example, in your paintcomponent(), you can go to:
public void paintComponent(Graphics g) { super.paintComponent(g); AttributedString as = new AttributedString("I love you 104 gazillion"); as.addAttribute(TextAttribute.SUPERSCRIPT,TextAttribute.SUPERSCRIPT_SUPER,13,14); as.addAttribute(TextAttribute.FOREGROUND,Color.RED,2,6); g.drawString(as.getIterator(),20,20); }
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码