devxlogo

Event handling with multiple scrollbars

Event handling with multiple scrollbars

Question:
I’m trying to work on the basics of event handling. I found it easy to set one label and have the scrollbar change the value of the label. I added a few more scrollbars, each with a separate label. When I move any scrollbar, only the first label value changes. How do you configure handleEvent to work with multiple scrollbars?

Answer:
Rather than override handleEvent, you shouldregister an AdjustmentListener for each scrollbarand place the appropriate label value changingcode in the AdjustmentListener’s adjustmentValueChanged method.

devx-admin

Share the Post: