Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

superscript text JTextArea  RSS feed

 
Nikos Stavros
Ranch Hand
Posts: 243
Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do I write superscripted text onto a JTextArea?
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In a JTextArea, you can't. You can use HTML in a JTextPane or JEditorPane, which is the simplest way to accomplish what you want. You can also do it directly in those classes, which support styled text, but it's quite a bit more complicated than just using HTML.

Set to text of a JTextPane to something like



and you should see the superscript.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to "Swing/AWT/JFace/SWT" for further discussion.
 
Nikos Stavros
Ranch Hand
Posts: 243
Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for your advice

I'm not how to include that in my code
<HTML>E = mc<sup>2</sup></HTML>


can someone add a few more lines of java code
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!