Article View: borland.public.jbuilder.java.swing
Article #11945re : jscrollpane & scrollbars
From: Ron Piterman
Date: Wed, 17 Mar 1999 00:00
Date: Wed, 17 Mar 1999 00:00
57 lines
2064 bytes
2064 bytes
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:
<54D181D619CED11199730060087509C4478AD7@PPMSRV01>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<36ED47E2.43DF7748@co2w3.fr>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: 111d45,76e2b96df874d99b X-Google-Attributes: gid111d45,public From: Ron Piterman <RonP@T-Online.de> Subject: re : jscrollpane & scrollbars Date: 1999/03/17 Message-ID: <54D181D619CED11199730060087509C4478AD7@PPMSRV01> X-Deja-AN: 455900410 Content-Transfer-Encoding: quoted-printable Sender: Ron Piterman <RonP@T-Online.de> References: <36ED47E2.43DF7748@co2w3.fr> Content-Type: text/plain; charset="iso-8859-1" Organization: Another Netscape Collabra Server User Mime-Version: 1.0 Newsgroups: borland.public.jbuilder.java.swing