2 Replies Latest reply: Nov 5, 2007 5:49 AM by 807600 RSS

    subscript string

    807598
      Hi...

      I want to put some simple chemistry things in a tooltiptext (like H20 to water), but I dont know how to put the number (in this case, '2') as subscript ("smaller and under").

      How do I do that?
        • 1. Re: subscript string
          800382
          setToolTipText("<html>H<sup>2</sup>0</html>");
          • 2. Re: subscript string
            807600
            Another option is to use unicode symbols encoded in the String with the syntax \uCODE, replacing CODE with desired unicode code. For example, the subscript 2 is represented as \u2082

            So, H20 would become "H\u2082O" if you replace the 2 in the String "H2O".

            This solution has a better performance than the one using html tags in Swing components (as <sub>2</sub>) because it doesn't require HTML rendering.

            In this page http://theorem.ca/~mvcorks/cgi-bin/unicode.pl.cgi?start=2070&end=209F" you can find other subscript and superscript unicode codes.

            Edited by: oleguer on Nov 5, 2007 3:48 AM