Line break in JButton

1

I am developing a complete and beautiful periodic table for the course. But at the time of implementing jbutton it lets me put just a text, no space, line break and other phrases in other lines, as would a normal table. How do I break lines in the JButton? Example:

1
  Ex
    
asked by anonymous 08.11.2017 / 13:45

1 answer

1

Try:

button.setText("<html>1<br>Ex</html>");

Swing components allow you insert text as html > within them. It's a solution, though, in particular, I find that this form, if used with too much volume in a code, makes it difficult to read and maintain.

    
08.11.2017 / 13:54