File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Super and sub string in java to string

 
Laxmikant Kumbhare
Ranch Hand
Posts: 38
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to set sub script in java string !
Please any one help me!

 
John Jai
Rancher
Posts: 1776
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I fear there is one like setting a Subscript or Supersript in the String class. Can you elaborate more on your purpose? Do you want to show like that in a UI?
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Laxmikant Kumbhare wrote:I need to set sub script in java string !



Not possible. A String is just a sequence of character. It has no concept of font or style or any such thing. What you probably mean is that you want the display of some String in a GUI to be subscripted. If you can confirm that, and clarify your context a bit, somebody can help you.
 
Laxmikant Kumbhare
Ranch Hand
Posts: 38
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
YES, exactly! I want to display a subscripted string on UI......................../././././././.
 
Campbell Ritchie
Sheriff
Pie
Posts: 47293
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can have html tags on some Components, I think a JLabel, but I am not certain. Then you could write <sub>some text</sub> or similar.

I think that would be better discussed on the GUIs forum: moving thread.
 
Rob Spoor
Sheriff
Pie
Posts: 20393
47
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<sup> and <sub> are part of HTML3.2 and so there should be support for it in Swing. Create a JLabel and set its text to the HTML you want; it needs to start with <html>, and can then contain all the bold, underline, italic, superscript and subscript tags you want. For instance:

To specify superscript or subscript for an entire font that's also possible:
TextAttribute.SUPERSCRIPT_SUPER is an Integer with value 1; TextAttribute.SUPERSCRIPT_SUB is an Integer with value -1. You can use any value between -7 and 7 (inclusive) to increase the superscript / subscript level.
 
Laxmikant Kumbhare
Ranch Hand
Posts: 38
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot rob! I will use it.......
 
Rob Spoor
Sheriff
Pie
Posts: 20393
47
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome.
 
Laxmikant Kumbhare
Ranch Hand
Posts: 38
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you! I will post if I need some help
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic