🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Word Wrap in a JTextCompnent..

#9214
From: Joi Ellis
Date: Sun, 14 May 2000 00:00
87 lines
3776 bytes
Here's a snippet of code from an app I'm writing.  This is part of the
implementation of a lame pop-up help window.  In this case I forced it
to
wrap the text and NOT use a horizontal scroll bar.  (I loath horizontal
scrollbars!)

You should be able to see what you need to change to do the opposite.


        JTextArea wrappedthing = new JTextArea( thing.helptext );
        wrappedthing.setWrapStyleWord( true );
        wrappedthing.setLineWrap( true );
        wrappedthing.setRows(15);
        wrappedthing.setColumns(45);
        Dimension d = wrappedthing.getPreferredScrollableViewportSize();
        wrappedthing.setRows(0);
        wrappedthing.setColumns(0);

        JScrollPane scrollthing = new JScrollPane( wrappedthing );
        scrollthing.setPreferredSize(d);
        scrollthing.setVerticalScrollBarPolicy(
                            JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
        scrollthing.setHorizontalScrollBarPolicy(
                            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
        JOptionPane.showMessageDialog(
          null,
           scrollthing,
          "Help",
          JOptionPane.INFORMATION_MESSAGE );




Jacob wrote:
> 
> As far as I can see, there isn't a lineWrap property in either the
> JTextComponent, JEditorPane or JTextPane.
> 
> Thanks for any help,
> 
> Jacob
> 
> "Paul Furbacher [TeamB]" <pnf@home.com> wrote in message
> news:391B24ED.233F9323@home.com...
> > Jacob,
> >
> > Pleae do NOT cross-post or multi-post the same message!  This
> > message, and variants of it have appeared on just about every
> > newsgroup I've looked at in the past 15 minutes.  Send a single
> > message to a single, most appropriate newsgroup.  And be willing
> > to wait patiently for a response.
> >
> > We heard you.  Just because you don't get an immediate answer
> > doesn't mean that no one has seen this message.  Currently,
> > I'm thinking of a reply, but don't have a good one (see below
> > for some ideas).
> >
> > > I am sorry if this appears more than once. I tried to post this before,
> but
> > > it didn't show up. This will be the last repeat.
> > >
> > > I am trying to get rid of Word wrap in either a JEditorPane or
> JTextPane. In
> > > other words, I am putting the JTextPane/JEditorPane in a JScrollPane and
> i
> > > would like to have the horizontal scrollbar show up automatically.
> >
> > Did you set the "lineWrap" property of the text component
> > to false?
> >
> > In another message you mentioned flickering.  Given Swing's
> > general problems with painting, you may have to live with
> > that -- unless someone else knows a way around it in this
> > case.
> >
> >
> > Paul Furbacher (TeamB)

-- 
------------------------------------------------------------------------
Joi Ellis                    Software Engineer
Aravox Technologies          joi@aravox.com, gyles19@visi.com

No matter what we think of Linux versus FreeBSD, etc., the one thing I
really like about Linux is that it has Microsoft worried.  Anything
that kicks a monopoly in the pants has got to be good for something.
           - Chris Johnson
Technical Details
Message-ID: <391F212F.46B429ED@aravox.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <3919cf42@dnews> <391B24ED.233F9323@home.com> <391f1c76@dnews>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,a50bddc2e8e6dfde
X-Google-Attributes: gid111d45,public
From: Joi Ellis <joi@aravox.com>
Subject: Re: Word Wrap in a JTextCompnent..
Date: 2000/05/14
Message-ID: <391F212F.46B429ED@aravox.com>
X-Deja-AN: 623383339
Content-Transfer-Encoding: 7bit
References: <3919cf42@dnews> <391B24ED.233F9323@home.com> <391f1c76@dnews>
X-Accept-Language: en
Content-Type: text/plain; charset=us-ascii
Organization: Aravox Technologies
Mime-Version: 1.0
Reply-To: joi@aravox.com
Newsgroups: borland.public.jbuilder.java.swing