Article View: borland.public.jbuilder.java.swing
Article #1819Re: How can i make a jLabel multiline
From: Gillmer J. Derge [TeamB]
Date: Sun, 03 Aug 2003 15:01
Date: Sun, 03 Aug 2003 15:01
27 lines
1980 bytes
1980 bytes
"Kostas" <karadamoglou_k@yahoo.gr> wrote in message
news:3f2c338e$1@newsgroups.borland.com...
> Does anybody knows how i can make a jLabel multiline explicitly? I
tried to
> use "\n" but it didnt work.
One way is to use the HTML features of JLabel, and add a <br> tag in
your text.
label.setText("<html>line one<br>line two");
Another way, which lets the lines wrap automatically at whatever length
is appropriate, is to use a JTextArea instead and make it look like a
JLabel. Something like this. I may have forgotten a step, but you can
see the idea. Create a JLabel so you can copy the colors and font to
make them look the same.
textArea.setFont(label.getFont());
textArea.setBackground(label.getBackground());
textArea.setDisabledTextColor(label.getForeground());
textArea.setEnabled(false);
textArea.setEditable(false);
textArea.setLineWrap(true);
textArea.setWrapStyleWord(true);
--
Gillmer J. Derge [TeamB]
Technical Details
Message-ID:
<3f2d23bd@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-01!sn-xit-05!sn-xit-08!supernews.com!newsfeed.news2me.com!mephistopheles.news.clara.net!news.clara.net!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<3f2c338e$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,ffad5679ba1d2e06 X-Google-Attributes: gid111d45,public X-Google-ArrivalTime: 2003-08-03 08:09:40 PST From: "Gillmer J. Derge [TeamB]" <spam@gillmerderge.com> Newsgroups: borland.public.jbuilder.java.swing References: <3f2c338e$1@newsgroups.borland.com> Subject: Re: How can i make a jLabel multiline Date: Sun, 3 Aug 2003 11:01:20 -0400 Lines: 29 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 NNTP-Posting-Host: 65.110.133.233 Message-ID: <3f2d23bd@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1059922877 65.110.133.233 (3 Aug 2003 08:01:17 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-01!sn-xit-05!sn-xit-08!supernews.com!newsfeed.news2me.com!mephistopheles.news.clara.net!news.clara.net!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail