Article View: borland.public.jbuilder.java.swing
Article #8471Re: Progrmatically Scrolling a JTextArea in a JScrollPane to the last line
From: Larry Maturo
Date: Fri, 25 Aug 2000 00:00
Date: Fri, 25 Aug 2000 00:00
28 lines
1547 bytes
1547 bytes
Someone sent me the answer to this, so I thought I would share it with the group. Given that you JTextArea is named MyTextArea and your JScrollPane is named MyScrollPane you would use: getMyScrollPane().getViewport().setViewPosition(new Point(0,getMyTextArea().getMaximumSize().height)); -- Larry Maturo Larry Maturo <lmaturo@athensgroup.com> wrote in message news:39a6c7bb_2@dnews... > I want to use a JTextArea for output only, and I want the last line I > append to be visible at the bottom of the JTextArea. I also want a > user to be able to scroll-up to look at eariler messages if he needs > to, otherwise I would just use a JLabel. > > I can't find any way to programatically scroll to the bottom after > I use append to add a line at the bottom. It seems like it should > be simple, but apparently it isn't. > > -- Larry Maturo > lmaturo@athensgroup.com > > >
Technical Details
Message-ID:
<39a6cad2_1@dnews>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<39a6c7bb_2@dnews>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,a51abcebed13651a X-Google-Attributes: gid111d45,public From: "Larry Maturo" <lmaturo@athensgroup.com> Subject: Re: Progrmatically Scrolling a JTextArea in a JScrollPane to the last line Date: 2000/08/25 Message-ID: <39a6cad2_1@dnews> X-Deja-AN: 662486142 References: <39a6c7bb_2@dnews> X-Priority: 3 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 X-Trace: 25 Aug 2000 12:36:50 -0800, 216.30.5.178 Organization: Athens Group X-MSMail-Priority: Normal Reply-To: "Larry Maturo" <lmaturo@athensgroup.com> Newsgroups: borland.public.jbuilder.java.swing