You can use HTML to display many components in Swing (see How to use HTML in Swing Components ), so you can create a line with underlined text and call JToggleButton.setText(String)or JToggleButton(String). for instance
new JToggleButton("<html><u>" + textToUnderline + "</u></html>");
(This closing tag </html>is optional, although I always include it).
source
share