🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.jbuilder.java.swing
4 messages
4 total messages Started by Hal Brooks Wed, 04 Feb 2004 17:39
Multiline Static
#1191
Author: Hal Brooks
Date: Wed, 04 Feb 2004 17:39
18 lines
1860 bytes
Hi all,

Sorry if this is a dumb question - I'm still fairly new to Swing.

Does Swing contain a multiline static control?  I have a JFrame
containing (among other things) a block of static text along the
bottom.  I'd like this block of text to resize nicely as the JFrame is
resized, automatically breaking onto multiple lines as necessary.  The
control itself doesn't have to grow vertically or anything - I can
make it tall enough to accomodate the maximum number of lines I expect
it to need.  It would just be nice if the control would handle the
wordwrap.

If there isn't such a thing, what's the best way to fake it?  Right
now I'm using a JTextArea, which does exactly what I want except that
the text is editable and the background color is wrong.  I considered
trying to turn off editing (how?) and changing the background color of
the JTextArea.  Is this the right way, or is there a better approach?
Re: Multiline Static
#1192
Author: pnichols
Date: Wed, 04 Feb 2004 23:12
34 lines
2323 bytes
Hal Brooks wrote:

> Hi all,
> 
> Sorry if this is a dumb question - I'm still fairly new to Swing.
> 
> Does Swing contain a multiline static control?  I have a JFrame
> containing (among other things) a block of static text along the
> bottom.  I'd like this block of text to resize nicely as the JFrame is
> resized, automatically breaking onto multiple lines as necessary.  The
> control itself doesn't have to grow vertically or anything - I can
> make it tall enough to accomodate the maximum number of lines I expect
> it to need.  It would just be nice if the control would handle the
> wordwrap.
> 
> If there isn't such a thing, what's the best way to fake it?  Right
> now I'm using a JTextArea, which does exactly what I want except that
> the text is editable and the background color is wrong.  I considered
> trying to turn off editing (how?) and changing the background color of
> the JTextArea.  Is this the right way, or is there a better approach?

You are using the right control, but the JTextArea does not have to be
editable and you cange the foreground and backfground colors to whatever
you wish.


Example:

jTextArea1.setBackground(new Color(204, 204, 204));
    jTextArea1.setEditable(false);
    jTextArea1.setText("This is a simple test to scroll lines of text across
multiple lines.\n" +
    "This is how it will work and display.");
    jTextArea1.setWrapStyleWord(true);
Re: Multiline Static
#1193
Author: Tor Iver Wilhelmsen (TeamB)
Date: Thu, 05 Feb 2004 08:07
6 lines
1040 bytes
pnichols <paul@comp.net> writes:

> jTextArea1.setBackground(new Color(204, 204, 204));

You can also have it "inherit" the background color by calling
setOpaque(false).
Re: Multiline Static
#1194
Author: Hal Brooks
Date: Thu, 05 Feb 2004 13:53
11 lines
1154 bytes
On 05 Feb 2004 09:07:48 +0100, tor.wilhelmsen@ergo.no (Tor Iver
Wilhelmsen (TeamB)) wrote:

>pnichols <paul@comp.net> writes:
>
>> jTextArea1.setBackground(new Color(204, 204, 204));
>
>You can also have it "inherit" the background color by calling
>setOpaque(false).

Thank you Paul and Tor!
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