Java JButton set sub script via HTML
import java.awt.BorderLayout; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; public class Main extends JFrame { public static void main(String[] args) { String lyrics ="<html>Bu<sub>tt</sub>on 3<br>" + "<font color=#7f7fdd>Subscript</font>"; JPanel panel = new JPanel(); panel.setLayout(new BorderLayout(10, 10)); JButton label = new JButton(lyrics); panel.add(label, BorderLayout.CENTER); JFrame f = new JFrame(); f.add(panel);/*from ww w. java 2 s. co m*/ f.pack(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setVisible(true); } }