The fastest and dirtiest way is to simply add <html> at the beginning of the text of the switch label. This will start the line break, but now you need to be careful about this text if it has <characters in it. It also supports the functionality of clicking on the label text, which is a click on the radio button.
Here's a cheap and fun example:
public class Test extends JFrame { public static void main(String[] args) { new Test(); } private Test() { Container c = getContentPane(); c.setLayout( new BorderLayout() ); c.add( new JRadioButton( "<html>I've got a very long text description that going to wrap over very long lines because I stuck an <html> tag at the start of its label string.</html>") ); setDefaultCloseOperation( WindowConstants.EXIT_ON_CLOSE ); setSize( 200,200 ); setVisible( true ); } }
source share