Superscript/Subscript in a JLabel?

How can I get a JLabel to print part of a string as a superscript or a subscript? Is there a clean way to do this when painting to a panel using Graphics2D's drawString method?

another option is unicode
JLabel label = new JLabel("H\u00B2O"); = H�O

Similar Messages

  • Greyed out superscript/subscript buttons

    Hi,
    When I'm using pages '11 I seem to have no control over when I can use the superscript/subscript icons on the toolbar.  Most of the time they are greyed out and I cannot use them at all.  Every now and again they are able to be used without me changing any settings?  Any ideas? Cheers!
    Calum

    You have to have your cursor blinking in the text layer
    You want to write in superscript so you click on the superscript icon and the you write
    Now you want to go back to normal text so you click on the superscript icon again.
    I found out it doesn't work as well in a text box in a Page layout document. No problem in the word processing document, neither in the text layer or in a text box.

  • How do you create superscripts subscripts in LabVIEW?

    I want to create superscripts subscripts in LabVIEW, but those are not options in the Applications Font Dialog Box. How do I do this?

    Hi,
    If you need users to create those formulas, it can get very complex. You
    cannot have font differences (or different fonts) in one string control.
    Even if you make a font with sub and superscript included, this is no
    solution.
    If you need a static formula on the front panel, make it by using several
    text boxes. For Asubscript(2)=Asubscript(1)Xsuperscript(2), one text is A =
    A X B. The other text is smaller, and has 2 1 in it. The last has a 2
    in it. When placed in the right position, it will make a fine formula.
    If the formula must be user editable, or changeble from the program, ActiveX
    is a solution. Microsoft Rich Text Box comes to mind. However, you must make
    the interface to make the selected text sub or superscript yourself. (Or
    control i
    t from the program.) A webbrowser control in combination with
    MathML also seems logical. Both solutions are not for the faint or heart...
    Regards,
    Wiebe.
    "Jim Kane" wrote in message
    news:[email protected]..
    > I want to create superscripts subscripts in LabVIEW, but those are not
    > options in the Applications Font Dialog Box. How do I do this?

  • Superscripts/Subscripts Not Available in Tables?

    I've noticed that I cannot format text as a superscript/subscript if the text is in a cell of a table. Once the cell loses focus, the text goes back to plain old default format. Is there something I should be doing?
    My workaround thus far has been to use MathType, but that's hardly an appropriate fix.
    I've tried this in Pages & Keynote as well...no luck in either case.
    Pubb

    Hi Jerrold
    If I remember well, the cell must be containing text, if it's a numeric one, the styles created from Format > Font > Baseline disappear when the focus is no longer in the cell.
    In the Help they are described for TEXT. A numeric value is not TEXT.
    Making Text Subscript or Superscript
    You can raise or lower text from its baseline.
    To make text subscript or superscript:
    1 Select the text you want to raise or lower, or click where you want to type new text.
    2 To create a subscript or superscript that has a smaller font size than the text it accompanies, choose Format > Font > Baseline > Subscript. Or choose Format > Font > Baseline > Superscript.
    To raise or lower text relative to the other text on the same line, choose Raise or Lower from the Baseline submenu.
    To restore text to the same baseline as the body text, choose Use Default from the Baseline submenu.
    To specify a precise amount to raise or lower text, use the Text inspector. Click
    Inspector in the toolbar, click Text, click More, and then use the Baseline Shift controls.
    You can add Subscript and Superscript icons to the toolbar. Choose View > Customize Toolbar, drag the icons to the toolbar, and then click Done.
    Yvan KOENIG (from FRANCE jeudi 5 février 2009 21:49:27)

  • Write Superscript/Subscript Characters in Description Field

    How to Write Superscript/Subscript Characters in Description Field?

    aqeeliqbal2008 wrote:
    Follow following path on your windows - start all programaccessories -- system tool -- character map.Here select the font as "lucida sans UNICODE". And here you will get symbol subscript 0 to 9.Select it, copy it and paste it in SAP wherever required.
    The ones I mentioned from Wikipedia and lucida sans UNICODE are unicode characters... Both have same value, for example superscript 2 ( ² ) has uni-node value of U+00B2. 
    If it's working it does mean your system supports unicode in longtext.

  • Why aren't they any superscript/subscript controls for text?

    Why aren't they any superscript/subscript controls for text?

    Hello,
    Please refer to Corey's reply on forum post : http://forums.adobe.com/message/4406018
    Hope this helps.
    Regards,
    Sachin

  • Odd superscript/subscript behavior

    Hi all
    I wanted to format a subscript character in Pages today, but both subscript and superscript were grayed out in the tool bar and also in the menu (Format>Baseline). however, the keyboard shortcut "Control - Command- -" worked fine.
    Can anyone explain this? I was using Times New Roman, so nothing fancy.
    Paul

    Thanks Paul, I have your file.
    I got no font warning, the TNR seems to match to mine. I am have no problem with the subscripting on both my own typing of SiO2, and yours.
    I am running OSX 10.6.8 and Pages 4.05.
    The only thought is a quirk in Lion and the latest Pages, there have been some problems with typing and with keyboard shortcuts.
    Peter
    PS Run your spellchecker over the document, or employ a nitpicking subeditor type like me to check it for you.

  • I can't change advanced type values (superscript & subscript)

    When i am trying to use subscript and superscript my text disappears. I think first that it is related to my font but when i open Preferences/Advanced Type I saw that both size and location values of superscript and subscript are zero. Everytime i changed them and they turns zero again. I want to reset this values and set as default permanently.
    Thank you for answers.
    I am using InDesing with my native language (Turkish) because Adobe offers student edition only in native language.
    (I hope they will offer English version also. Because it's translation is really terrible.)

    Defaults for new text are set by making changes with no text selected (and no active text cursor). If there is an open document, the default will apply only to the current document, no open documentes will apply to all new files. No change in defaults will alter any existing text, nor the default for any existing document that is not active at the time the change is made, so any existing files will need manual corrections.

  • Superscript & Subscript in Contribute

    Just wondering how you would apply add sub & super script
    formatting... in html you would simple put
    <sub>2</sub>, but in contribute you can't edit in html
    - thought it may be via 'Insert Special Characters' but there is
    nothing there.
    Anyone know?
    Thanks

    When you have CS3 you can insert a HTML snippet (main menu
    > Insert > HTML Snippet). The admin has to give you the
    proper rights.
    Set rights:
    1. go to main menu Edit>Administer websites>Users and
    Roles>Edit role settings>Editing
    2. check the option to insert HTML Snippets
    If you have an older version you have to insert the code
    using an external application (Main menu> File > Actions >
    Edit page source in external application). In this case the admin
    also needs to give you proper rights.
    Set rights:
    1. go to main menu Edit>Administer websites>Users and
    Roles>Edit role settings>Editing
    2. check the option to enable editing in external
    appllication

  • How to fix faux subscripts/superscripts made with baseline shifts

    Hello all.
    There is a script on the forums used to convert locally formatted styles to character styles – Preserve Local Formatting script and CS4
    It is a brilliant script, but as I have unexpectedly found out (and would have found out if I read the post in more detail) is that any "faked" sub/superscripts created with baseline shifts won't work. To quote the other thread:
    The script searches for attributes such as "superscript", "subscript", "small capitals". If small caps are faked in the document with capitals in a smaller font, the script will not find them. If superscript or subscript are faked in the document with a smaller font size and some baseline shift, the script will not find them.
    Initially I didn't think this would ever be a problem... I thought "who the hell would make a subscript or superscript like that? wouldn't they just click the subscript or superscript buttons?"... unfortunately, no!
    I thought a solution would be to make a GREP that could be added to a findchangebylist script that ships with InDesign. First thing to do would be to create a GREP to look for any positive baseline shift and change it to superscript; and a GREP to search for any negative baseline shift and change it to a subscript. Sounds simple... until I tried to implement it, as the dialog won't take a + or - by itself... it has to be a proper value.
    Has anyone else faced this issue, and if so, what was the solution/outcome?
    Colin

    @Rob: Perhaps I should have given some background for what I was trying to do.
    I have a client who is importing dozens of pages of simple chemical equations from microsoft word and it is in the word file that the baseline shift method of creating subs/supers was done. What my client wanted to do was import the text without losing important appearance details such as this, and bolds/italics, but then be able to assign his own paragraph styles without faux sub/supers returning to a regular style. My procedure to the client was to:
    Import said word file into indesign file that contains appropriate paragraph/character styles to be applied;
    Run the default "findchangebylist.jsx" to remove any double spaces, tabs etc.
    Run a modification of Jongware's "preptext" script that will apply to all text frames rather than the current text frame.
    This was working well until we both noticed H2SO4 did not have the numbers as subs, even though the word file clearly did. Closer inspection on the word file showed that the subscript button was not toggled, but the baseline shift had been, hence why the preptext script had missed a key piece of formatting.
    With the preptext script, items that had subscript and superscript locally applied to the text would now be assigned "Sub" and "Super" character styles, and from there I agree - the more discerning typesetter could to into the character style and make the apperance of the said subs/supers more appealing. I believe a way of using the opentype subs/supers would be to replace the words SUBSCRIPT and SUPERSCRIPT in the said script to be OT_SUBSCRIPT or OT_SUPERSCRIPT respectively, provided an opentype font was being used for the formatting.
    So in this instance, this script serves a rather specific purpose of fixing this particular document, rather than being applicable on a wider scale.
    It is also important for anyone working with epubs to note that subs/supers made with baseline shifts (whether applied as character styles or not) will not appear in the resulting epub. Subs/supers made with the subscript/superscript buttons (again, whether applied as a character style or not) will appear in a resulting epub, so this is another consideration (I don't know if this is true if a customised CSS has been applied, but for straight export to epub from InDesign, it appears to be the case). This can be said for other forms of faux styles, such as skewing type to make a faux italic.
    @Peter: I agree, there isn't a perfect solution, but for the situation that I have, the script does what it is intended to do.
    It should be noted for readers of this post that this script is specifically purpose-driven, and that I would not use this script if a document contained:
    fractions made using baseline shifts;
    character or paragraph formatting that used baseline shifts;

  • Subscript & SuperScript in Crystal Report

    hi ,
    I m developing application which contain information about chemical compound. all formula of chemical compound contains superscript & subscript. I store value in database using sub & sup Tag .but crystal report does not support these tag
    how can we change formula to subscript & superscript form in crystal Report as following
    NH4Al(SO4)2.12H2O
    Any help will be appreciated
    Thanks in advance
    Rupesh Kumar Swami
    Software Engineer,
    Integrated Solution,
    Bikaner (India)

    I think you might be able to use formulas to achieve what you are looking for. I found this kbase <a href="http://technicalsupport.businessobjects.com/KanisaSupportSite/search.do?cmd=displayKC&docType=kc&externalId=c2010059&sliceId=&dialogID=1988273&stateId=1 0 1986304" target="_blank">c2010059</a>, on the BOBJ support site that provides a series of steps to create formulas to achieve superscript text. The kbase uses dates as an example but you should be able to do the same for your needs. The similar should be possible for subscript text. Hopefully this helps you out! -MJ

  • Creating subscript or superscript in a mail response.

    I am attempting to reply to an email in the MAIL App.  I am having trouble making subscripts or superscripts that are required in my response.  Any help would be appreciated. I am using the Yosemite Operating System.

    [Updated to solve Superscript, Subscript, and Strike-through text cases. - /viking]
    Mail does not offer any Superscript, Subscript, or Strike-through style capability, but you can first create them in TextEdit, and then these styles will be available in Mail.
    TextEdit
    Superscript and Subscript
    Type the arbitrary text "ka" (without the quotes). Select the letter "a", and then choose Format > Font > Baseline > Superscript. The character levitates. On the left end of the TextEdit toolbar, there is a ¶ selector button. Click this and choose Show Styles… .
    In the styles panel, you will see the superscripted letter "a" and below it, the current font info and the term Raised. Leave Document Styles selected, and simply click the Add to Favorites button. A sheet will drop down allowing you to name this style, and I suggest you call it Superscript. Leave the two checkboxes unselected, and click Add.
    The "a" is still selected. You want to return this to normal, so click the ¶ style selector on the toolbar again, and choose default. Reselect the "a" character, and now choose Format > Font > Baseline > Subscript. From the preceding ¶ style selector, select Show Styles… again. This time, it says that it is Lowered. Click Add to Favorites, and name this Subscript.
    Strike-through
    While still in TextEdit, add and select an arbitrary word of default styled text. Choose Format > Font > Show Fonts. In the Fonts toolbar, there is a drop-down button offering single and double strike-through styles. Select Single for normal strike-through. If you want a red strikebar, choose the Color menu option, and pick red from the color chooser — before selecting Single from the strike-through menu.
    Now, you have a word with a strike-through style applied. Select this word, and from the familiar ¶ style selection menu, Show Styles… again. Choose Add to Favorites, and when the naming sheet slides down, call it Strike-through, or Red Strike-through (if pertinent).
    Now, Superscript, Subscript, and Strike-through are now selectable Favorites on your Show Styles menu.
    Apple Mail
    Select the text that you want to apply a style too. Right-click on that selected text. From the pop-up menu, choose Font > Styles… . A sheet should drop down with Favorite Styles enabled. Click on the blue-arrows adjacent to Default. Choose Superscript, Subscript, or Strike-through as appropriate. When you click Apply, your preferred style is applied to the selected text.
    When you want to resume with regular text, spacebar after your effect, and then do the right-click, Font > Styles… again, and this time, click Default and Apply. You will be back to a default font baseline.

  • HTML in JLabel

    Hi everybody. I've a strange problem with the Swing application I'm writing: I'm using JLabels to display some html code because i need special character formats (superscript/subscript).
    Now when I use:
    jLabel1.setText("<html>0,12m<sup>2</sup></html>")in the jLabel "0,12" becomes "0.12"; while when I cut out the <sup> part:
    jLabel1.setText("<html>0,12m</html>")I get the correct display of "0,12".
    How come this is happening?
    Thanks in advance for your help.
    Edited by: NeedForSpeed73 on Nov 25, 2008 11:07 AM

    It works for me using 1.5.0_14. I tried the String in both the constructor, and in setText(...)
    import java.awt.*;
    import javax.swing.*;
    public class SwingTest extends JFrame
      public SwingTest()
        String html = "<html>0,12m<sup>2</sup></html>";
        JLabel label1 = new JLabel(html);
        JLabel label2 = new JLabel();
        label2.setText(html);
        JPanel p = new JPanel(new GridLayout(0,1));
        p.add(label1);
        p.add(label2);
        add(p);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        pack();
        setLocationRelativeTo(null);
        setVisible(true);
      public static void main(String[] args)
        SwingTest sw = new SwingTest();
    }

  • Superscripts using pages on ipad?

    Can I create superscripts, subscripts, do strikeout of text, and highlight text using Pages on the iPad?
    Thanks
    Jim Taylor

    Have you tried inserting an explicit page break instead of extra blank lines? It might affect the page layout algorithm differently.
    I should mention that I have not experienced the problem you describe, so I cannot test this theory.
    Message was edited by: markwmsn - insert disclaimer

  • Superscript test in BO WEBI Report

    Can any one help me to create superscript text BO WEBI(XI R2) report.
    For EX: MicrosoftTM (Here TM should be super scipt.) Unable to apply format here also. 
    I don't want to do this in HTML, because if we export report to PDF or XLS, instead of applied format, HTML code will come.
    Is there any workaround to achive this.
    Please help.

    Hi Ravi,
    What's the solution? What did you do to make it work in PDF?
    I found a link where they found a solution which works in Excel & HTML.
    Re: How to use superscript & subscript in WEBI 4.1
    Thanks & Regards.

Maybe you are looking for

  • TouchPad driver installation on Pavillion g7-64 Windows 7 Home Premium?

    Hello,    Irratic operation of Synaptics TouchPad so I uninstalled it from my computer and tried to install the drivers from the HP site.  The drivers will not install correctly.  I tried this several times.  Please help with either a downloadable dr

  • Our ipods wont sync purchased music since the itunes update

    After our most recent itunes update, our purchased music doesn't sync with our ipods.  You must click on the song and drag it to the playlist you want.  Also, we are unable to fine a sort feature that shows purchaced music by most recent purchace, on

  • What happens when UNDO space is full? Transaction takes more time to ERROR?

    I have a long running transaction (more than 3 hours), and at the same time other operations are occurring on different tables, using the same UNDO space. Sometimes we see ORA-30036, but this error occurs very late in the process. The transaction nor

  • While accessing Integration Directory (No authorization for this action)

    Hi, I am getting below error, while accessing  Integration Directory it is showing (No authorization for this action I had provided necessary authorization to XI* users & j2ee_guest, j2ee_admin. below error is in application.log #1.5#0019BB24F5460065

  • Adobe Flash Player Actionscript errors

    I keep getting these pop up error messages.  I did some research and see that my computer (new) may be running the "debugging" version.  As Adobe Flash Player is embedded in Windows 8.1 (to which I am a new user of), I can't figure out how to change