Line break in Jbutton

Asked

Viewed 547 times

1

I am developing a complete and beautiful periodic table for the course. But when it comes to implementing jbutton it lets me put only one text, no space, line breaks and other sentences in other lines, as would be a normal table. How do I break lines in Jbutton? Example:

1
  Ex

1 answer

2

Try:

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

Swing components allow you insert text as html within them. It’s a solution, although I find that this form, if used with a lot of volume in a code, makes it difficult to read and maintain.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.