🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #1192

Re: Multiline Static

#1192
From: 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);
Technical Details
Message-ID: <40217ac6@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <40212ca3.43762096@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,692e8df434532b1d
X-Google-Attributes: gid111d45,public
X-Google-ArrivalTime: 2004-02-04 15:10:20 PST
Message-ID: <40217ac6@newsgroups.borland.com>
From: pnichols <paul@comp.net>
Subject: Re: Multiline Static
Newsgroups: borland.public.jbuilder.java.swing
Reply-To: paul@comp.net
Date: Wed, 04 Feb 2004 18:12:07 -0500
References: <40212ca3.43762096@newsgroups.borland.com>
Lines: 34
Organization: clc
User-Agent: KNode/0.7.2
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7Bit
NNTP-Posting-Host: 68.71.188.25
X-Trace: newsgroups.borland.com 1075935942 68.71.188.25 (4 Feb 2004 15:05:42 -0800)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail