0

I want to make my I in this JLabel have subscripts. Is this possible?

for (int j = 0; j < col; j++)
        {
            gbc.gridy = 1;
            gbc.gridx = j;
            if (j != (col - 1))
                header[j] = new JLabel("I" + (j + 1));
            else
                header[j] = new JLabel("x");
            matrix.add(header[j], gbc);
        }
Jessie
  • 363
  • 2
  • 6
  • 20

1 Answers1

5

Yes, you may use HTML for that.

Example:

JLabel label2 = new JLabel("<html> a<sub>x</sub> </html>");
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Iootu
  • 344
  • 1
  • 6