views:

24

answers:

1

I made few checkboxes using swing in Java. I want to write a superscript text for the checkboxes but I'm not sure how.

The code currently looks like this.

JCheckBox hCheckBox = new JCheckBox("[M + H]+");

I want to have "+" sign inside the JCheckBox parameter superscripted. What's an easy way to do this?

Thank you in advance.

+1  A: 

Java buttons support html in their text. You need to format the string a little differently though. Try this:

JCheckBox hCheckBox = new JCheckBox("<html>[M + H]<sup>+</sup></html>"); 
Starkey
Thank you so much! That was easy it looks like I was looking for it the hard way by going through libraries haha.
js0823