import java.awt.event.AdjustmentListener; import java.awt.event.AdjustmentEvent; import javax.swing.JScrollBar; public class ScrollBar extends JScrollBar implements AdjustmentListener { // My private ID number, so I can tell my scrollbar's apart private int id; public ScrollBar (int id) { // Customize properties of our ScrollBar // Named static constant setOrientation (HORIZONTAL); setMinimum (0); setMaximum (100); // Initial value setValue (25); this.id = id; addAdjustmentListener (this); } public void adjustmentValueChanged (AdjustmentEvent event) { System.out.println ("Scrollbar " + id + ": new value = " + getValue()); } }