Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How do I add Scrollbars to a JTree???

3,096 views
Skip to first unread message

Dirk

unread,
Jul 21, 1999, 3:00:00 AM7/21/99
to
I have a little problem.
I have a JInternalFrame with a JTree in it. When the JTree exceeds the
visible area there appear no scrollbars.
How do I add this scrollbar functionality to the JTree???
It would be nice if anyone can help me

Dirk

lowtech

unread,
Jul 21, 1999, 3:00:00 AM7/21/99
to
Let's say you have JInternalFrame iFrame, then do -

iFrame.getContentPane()
.add(new JScrollPane(jTree), BorderLayout.CENTER);

[assuming you have BorderLayout for your contentPane]

-sandip


In article <3795EDCC...@rz.uni-karlsruhe.de>,


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.

Christian Kaufhold

unread,
Jul 21, 1999, 3:00:00 AM7/21/99
to
Dirk <ua...@rz.uni-karlsruhe.de> wrote:
> How do I add this scrollbar functionality to the JTree???
[...]

You put the JTree into a JScrollPane.


Christian

Jemiah Westerman

unread,
Jul 21, 1999, 3:00:00 AM7/21/99
to

To add scrollbars to (pretty much) any swing component place it in a
JScrollPane.

JTree someCoolTree = new JTree();
JScrollPane someCoolPane = new JScrollPane( someCoolTree );

or

JTree someCoolTree = new JTree();
JScrollPane someCoolPane = new JScrollPane();
someCoolPane.add( someCoolTree );

If you check out the Java Tutorial from java.sun.com it has some good stuff
on designing UI with swing. You may want to take a look, it has lots of good
stuff on all the swing components.

Good luck,

Jemiah Westerman


Dirk wrote in message <3795EDCC...@rz.uni-karlsruhe.de>...


>I have a little problem.
>I have a JInternalFrame with a JTree in it. When the JTree exceeds the
>visible area there appear no scrollbars.

>How do I add this scrollbar functionality to the JTree???

Arno Hütter

unread,
Jul 21, 1999, 3:00:00 AM7/21/99
to
Hi!

Maybe you should embed your JTree within a JScrollPane...

Regards,
Arno Huetter

Dirk schrieb in Nachricht <3795EDCC...@rz.uni-karlsruhe.de>...

0 new messages