In quest’articolo spiegherò come inserire del testo all’interno di un JButton su più righe.
Il trucco sta nel settare come testo del bottone del codice html. Infatti se volessimo creare un bottone con testo su 2 righe si potrebbe, ad esempio, usare l’html seguente:
<html><div align='center'>Riga 1<br>Riga 2</div></html>
Da notare l’uso dell’align che serve a centrare le due righe all’interno del bottone.