[3343] in java-interest

home help back first fref pref prev next nref lref last post

Re: scrollbars

daemon@ATHENA.MIT.EDU (Per Danvind)
Wed Nov 8 05:41:40 1995

To: "Dorothy E. Harris" <dharris@sispro.sis.rpslmc.edu>
cc: java-interest@java.sun.com
In-reply-to: Your message of "Tue, 07 Nov 1995 15:34:17 CST."
             <199511072134.PAA18724@sispro.sis.rpslmc.edu> 
Date: Wed, 08 Nov 1995 10:00:54 +0100
From: Per Danvind <perry@cdt.luth.se>

> I am working in the pre-Beta JDK.  I would like to add a scrollbar
> to a slightly modified version of the SpreadSheet demo.  Does anyone
> know how to do this?  I copied some come from the awt/test module,
> ScrollbarTest.java.  This produces a scrollbar, but in the wrong
> place, and it is ineffectual - moving the scroller does nothing for the
> spreadsheet.  I tried adding an addNotify statement after creating the
> scrollbar.  The scrollbar comes up as before, but then when I resize the
> spreadsheet (using the mouse), I get a core dump.  None of my code
> seems to be involved, and it appears that the applet code is trying
> to notify a nonexistent object.

When you add a scrollbar to a container, you actually don't do much more
than add the graphical appearance of the scrollbar. To get its function
too, you will have to handle the events sent when it is manipulated.

In an applet it is easy, just add proper actions for the scrollbar events
in the handleEvent() method (move the scrollable contents according to
the event handled).

In a standalone app it appears that to catch the events sent, you have to
extend either of the containers containing the scrollbar or the Scrollbar
class itself. Otherwise I see no way of getting hold of the scroll events.
When you have the extended component, you just use the handleEvent()
method as in the applet case.

Hope it helps.

--
Per

-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post