swing - Java (JLabel spacing) -


i want jlabel display "hi, name bob"

however, when coded: jlabel.settext("hi, name bob");

the spaces "consumed" , output read "hi, name bob"

can please me on this? in advance

here 2 ways both have same effect. 1 sets font monospaced while other marks text html preformatted (which uses monospaced font & preserves spaces , tabs).

string text = "hi,      name bob";  // ...  jlabel l = new jlabel(text); l.setfont(new font(font.monospaced, font.plain, l.getfont().getsize())); ui.add(l); ui.add(new jlabel("<html><body><pre>" + text)); 

having said that, agree @madonah & @maraca best handled in 2 labels, using layouts (borders , padding) achieve required result.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -