Article View: borland.public.jbuilder.java.swing
Article #11947Re: re : jscrollpane & scrollbars
From: Stephen Henderson
Date: Wed, 17 Mar 1999 00:00
Date: Wed, 17 Mar 1999 00:00
65 lines
2821 bytes
2821 bytes
Sure, but doesn't that just force the bars to always be present?
Perhaps the original post intended to say that the JScrollPane was not
painted correctly until a inital resizing occured? I'm getting such
behavior with my applets (my laboriously crafted UIs are not correctly
painted until at lesat one resize occurs at runtime...) and I don't
understand why.
Any thoughts?
Ron Piterman wrote:
>
> Hi,
> This is very simple, all you have to do is (for example)
>
> class myPanel extends JPanel {
> myPanel(ListModel model) { //Constractor
> setLayout(new BorderLayout());
> JList list = new JList(model); // or new JList();
> JScrollPane scroll = new JScrollPane(
> list,
> JScrollPane.VERTICAL_SCROLL_BAR_ALWAYS,
> JScrollPane.HORIZONTAL_SCROLL_BAR_ALWAYS
> );
> add(scroll,BorderLayout.CENTER);
> }
>
> or all in one :
>
> myPanel(ListModel model) { //constructor)
> super(new BorderLayout());
> add(
> new JScrollPane(
> new JList(model),
> JScrollPane.VERTICAL_SCROLL_BAR_ALWAYS,
> JScrollPane.HORIZONTAL_SCROLL_BAR_ALWAYS
> ), BorderLayout.CENTER
> );
> }
>
> it is important NOT to set the List's preferred size, but, if you really
> need it use
> scroll.setPreferredSize(...);
>
> good luck
>
> ron
>
> ron.piterman@usa.net
>
> > -----Urspr�ngliche Nachricht-----
> > Von: Mari-Mai HENAFF [SMTP:mari-mai.henaff@co2w3.fr]
> > Ver�ffentlicht am: Montag, 15. M�rz 1999 18:48
> > Im Ordner: swing
> > Unterhaltung: jscrollpane & scrollbars
> > Betreff: jscrollpane & scrollbars
> >
> > I have pbm using a jscrollpane to display a Jlist.
> > I've set jscrollpane.setAutoscrolls(true). But the
> > scrollbar are not displayed, although we can't see
> > the entire jlist and we would need scrollbars. I just
> > resized my window, ad then the scrollbars appeared ...
> > If anyone knows why ?
> > thank you very much.
> > m.Henaff
Technical Details
Message-ID:
<36F03363.F838F635@aem-tx.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<36ED47E2.43DF7748@co2w3.fr> <54D181D619CED11199730060087509C4478AD7@PPMSRV01>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: 111d45,76e2b96df874d99b X-Google-Attributes: gid111d45,public From: Stephen Henderson <shenderson@aem-tx.com> Subject: Re: re : jscrollpane & scrollbars Date: 1999/03/17 Message-ID: <36F03363.F838F635@aem-tx.com> X-Deja-AN: 455904080 Content-Transfer-Encoding: 8bit References: <36ED47E2.43DF7748@co2w3.fr> <54D181D619CED11199730060087509C4478AD7@PPMSRV01> X-Accept-Language: en X-Sender: "Stephen Henderson" <@mail.aem-tx.com> (Unverified) Content-Type: text/plain; charset=iso-8859-1 Organization: Another Netscape Collabra Server User Mime-Version: 1.0 Newsgroups: borland.public.jbuilder.java.swing