Article View: borland.public.jbuilder.java.swing
Article #12353Re: JTextArea and JScrollPane - no scrollbars?
From: Paul Waldo
Date: Wed, 13 Jan 1999 00:00
Date: Wed, 13 Jan 1999 00:00
47 lines
1886 bytes
1886 bytes
Try using this JScrollPane constructor
public JScrollPane(Component view)
rather than using the viewport to add the component. Your code would
look like this:
JTextArea jta = new JTextArea();
JScrollPane jsp = new JScrollPane(jta);
I hope this helps.
Paul Waldo
Michael Appelmans wrote:
> When I place a JTextArea in a JScrollPane and add succesive lines of
> text using add method no scrollbars appear and I can't see lines of
> text past the bottom of the frame. Any suggestion on what I am doing
> wrong with textarea?
>
> relevant code....
> public MyJFrame extends JFrame{
>
> ....
> JScrollPane jsp = new JScrollPane();
> JTextArea jta = new JTextArea();
> ...
> jsp.getViewport().add(jta, null);
> bevelPanel1.setLayout(borderLayout1);
> bevelPanel1.add(jsp, BorderLayout.CENTER);
> this.getContentPane().add(bevelPanel1, BorderLayout.CENTER);
> ....
> public static void main(String[] args) {
> MyJFrame jf = new MyJFrame();
>
> for (int i = 1; i < 50; i++)
> jf.jta.addLine("Test: " + Integer.toString(i));
>
> Here I can't scroll to text below line 20 which is the size of the
> frame.
>
> Any help would be appreciated...
> Thanks
> Michael Appelmans
>
> Agility, Inc.
> *remove 123 to mail*
> mappelmans@123agility-inc.com
Technical Details
Message-ID:
<369CCB7E.E34CD9BD@bna.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<758mfd$qsn16@forums.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,852e538c8260ff1a X-Google-Attributes: gid111d45,public From: Paul Waldo <pwaldo@bna.com> Subject: Re: JTextArea and JScrollPane - no scrollbars? Date: 1999/01/13 Message-ID: <369CCB7E.E34CD9BD@bna.com> X-Deja-AN: 432174560 Content-Transfer-Encoding: 7bit References: <758mfd$qsn16@forums.borland.com> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii Organization: Another Netscape Collabra Server User Mime-Version: 1.0 Newsgroups: borland.public.jbuilder.java.swing