• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Super and sub string in java to string  RSS feed

 
Ranch Hand
Posts: 38
  • 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!

 
Rancher
Posts: 1776
  • 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?
 
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • 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
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
YES, exactly! I want to display a subscripted string on UI......................../././././././.
 
Marshal
Posts: 59745
188
  • 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.
 
Sheriff
Posts: 21423
94
Chrome Eclipse IDE Java Windows
  • 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
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot rob! I will use it.......
 
Rob Spoor
Sheriff
Posts: 21423
94
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome.
 
Laxmikant Kumbhare
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you! I will post if I need some help
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!