import java.awt.*;
import javax.swing.*;
public class practice9 {
public static void main(String[] args) {
JButton b = new JButton();
b.setBounds(10, 10, 150, 150);
JLabel l = new JLabel("ell");
l.setText("<html>+ax<sup>2</sup>+bx<sub>2</sub>+c</html>");
b.add(l);
JTextField t = new JTextField();
t.setBounds(10, 300, 150, 150);
t.add(l);
JFrame f = new JFrame("");
f.setVisible(true);
f.setLayout(null);
f.setBounds(10, 10, 500, 500);
f.add(b);
f.add(t);
}
}
I was working on a calculator and wanted to display superscripts. I was successful in doing so on a label using the HTML, but failed to repeat it on a text field.
Is it impossible to do it in a text field (i.e. display sub/superscript) or is there a way?