Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JLabel with multiple lines and alignment to the right

I searched through many posts and figured out that JLabel supports HTML. So I can do

JLabel search  = new JLabel("<html>Search<br/> By:</html>");

to get multiple lines. Above code will result in

Search  
By:  

However, What I want is something like

Search  
   By: 

Adding spaces before "By:" will work only when the window is not resizable(And very silly lol). Can anyone tell me how to modify this code to make it work as I wanted?

like image 226
Fallautumn Avatar asked Apr 09 '15 23:04

Fallautumn


1 Answers

Slightly simpler HTML than seen in @MadProgrammer's answer:

new JLabel("<html><body style='text-align: right'>Search<br>By:");
like image 154
Andrew Thompson Avatar answered Sep 19 '22 21:09

Andrew Thompson