1

is there a way to format jLabel text to show a number with power index?

For example I would like a label to show 2^2 as 2² or x^2 as x²

Marius Katinas
  • 470
  • 1
  • 5
  • 13

1 Answers1

3

As JLabel support HTML, you can use HTML to show x² as follow:

JLabel l = new JLabel("<html>x<sup>2</sup></html>");
ashiquzzaman33
  • 5,781
  • 5
  • 31
  • 42