🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.jbuilder.java.swing
5 messages
5 total messages Started by Katerina K. Mon, 17 Jan 2005 14:18
Jlabel and HTML formatted text
#679
Author: Katerina K.
Date: Mon, 17 Jan 2005 14:18
21 lines
1511 bytes
Hello!
I have read that I can use HTML in components like JLabel in order to change 
the formatting of the text.

So I write something like this:

JLabel questionText = new JLabel();
questionText.setText("<html> <p style=\"text-align: justify\">  " + "My 
multiline text here...");

I expect that this will make my text "justified". Instead it looks like it 
is "centered". I have also tried with the other possible values for 
text-align (left, right, center) and all three of them work as expected. 
Java seems to ignore only "justify".
Any idea why this is happening?

I am using JBuilderX Enterprise with java version 1.4.2_01-b06.


Thanks a lot!
Katerina 
Re: Jlabel and HTML formatted text
#680
Author: Kevin Dean [TeamB]
Date: Mon, 17 Jan 2005 15:09
37 lines
2325 bytes
That would probably be because "justify" typically works only on every line 
but the last one in a paragraph (try it in a word processor to see what I 
mean).  Since your text is only one line long, the "justify" option won't 
apply.

-- 
Kevin Dean [TeamB]
Dolphin Data Development Ltd.
http://www.datadevelopment.com/

Please see Borland's newsgroup guidelines at
http://info.borland.com/newsgroups/guide.html

"Katerina K." <scorpio_gemini@hotmail.com> wrote in message 
news:41ebc94b$1@newsgroups.borland.com...
> Hello!
> I have read that I can use HTML in components like JLabel in order to 
> change the formatting of the text.
>
> So I write something like this:
>
> JLabel questionText = new JLabel();
> questionText.setText("<html> <p style=\"text-align: justify\">  " + "My 
> multiline text here...");
>
> I expect that this will make my text "justified". Instead it looks like it 
> is "centered". I have also tried with the other possible values for 
> text-align (left, right, center) and all three of them work as expected. 
> Java seems to ignore only "justify".
> Any idea why this is happening?
>
> I am using JBuilderX Enterprise with java version 1.4.2_01-b06.
>
>
> Thanks a lot!
> Katerina
> 
Re: Jlabel and HTML formatted text
#681
Author: Katerina K.
Date: Mon, 17 Jan 2005 15:37
21 lines
1702 bytes
As I wrote

JLabel questionText = new JLabel();

questionText.setText("<html> <p style=\"text-align: justify\"> " + "My 
multiline text here...");

which means that in the String is a Multi-line text!!! Of course there was 
no reason to copy all the text here (about 10 lines of text that do not mean 
anything to the newsgroup).

Katerina


"Kevin Dean [TeamB]" <NkOdSePaAnM@datadevelopment.com> wrote in message 
news:41ebd546@newsgroups.borland.com...
> That would probably be because "justify" typically works only on every 
> line but the last one in a paragraph (try it in a word processor to see 
> what I mean).  Since your text is only one line long, the "justify" option 
> won't apply.
>
Re: Jlabel and HTML formatted text
#683
Author: Kevin Dean [TeamB]
Date: Mon, 17 Jan 2005 16:50
26 lines
2024 bytes
It may well be then that the "justify" option is not supported.  There's 
source for a multi-line label here that may do what you want:

http://forum.java.sun.com/thread.jspa?threadID=459705&messageID=2104021
-- 
Kevin Dean [TeamB]
Dolphin Data Development Ltd.
http://www.datadevelopment.com/

Please see Borland's newsgroup guidelines at
http://info.borland.com/newsgroups/guide.html

"Katerina K." <scorpio_gemini@hotmail.com> wrote in message 
news:41ebdbcc@newsgroups.borland.com...
> As I wrote
>
> JLabel questionText = new JLabel();
>
> questionText.setText("<html> <p style=\"text-align: justify\"> " + "My 
> multiline text here...");
>
> which means that in the String is a Multi-line text!!! Of course there was 
> no reason to copy all the text here (about 10 lines of text that do not 
> mean anything to the newsgroup).
>
> Katerina
Re: Jlabel and HTML formatted text
#682
Author: Alexey N. Solofnenko
Date: Mon, 17 Jan 2005 18:43
5 lines
1248 bytes
Swing controls (at least used to) do not calculate the right boundary 
correctly. There was a code on internet how to fix right aligned text. 
Maybe it will fix your code too.

- Alexey.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads