JScrollBar: addAdjustmentListener(AdjustmentListener l) : JScrollBar « javax.swing « Java by API






JScrollBar: addAdjustmentListener(AdjustmentListener l)

 

import java.awt.BorderLayout;
import java.awt.event.AdjustmentEvent;
import java.awt.event.AdjustmentListener;

import javax.swing.JFrame;
import javax.swing.JScrollBar;

public class MainClass {
  public static void main(String args[]) throws Exception {
    AdjustmentListener adjustmentListener = new AdjustmentListener() {
      public void adjustmentValueChanged(AdjustmentEvent adjustmentEvent) {
        System.out.println("Adjusted: " + adjustmentEvent.getValue());
      }
    };
    JScrollBar oneJScrollBar = new JScrollBar(JScrollBar.HORIZONTAL);
    oneJScrollBar.addAdjustmentListener(adjustmentListener);


    JFrame frame = new JFrame("ScrollBars R Us");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(oneJScrollBar, BorderLayout.NORTH);

    frame.setSize(300, 200);
    frame.setVisible(true);
  }

}
           
         
  








Related examples in the same category

1.JScrollBar.HORIZONTAL
2.new JScrollBar(int orientation)
3.new JScrollBar(int orientation, int value, int extent, int min, int max)
4.JScrollBar: getBlockIncrement(int direction)
5.JScrollBar: getMinimum()
6.JScrollBar: getModel()
7.JScrollBar: getUnitIncrement(int direction)
8.JScrollBar: setBlockIncrement(int blockIncrement)
9.JScrollBar: setFocusable(boolean focusable)
10.JScrollBar: setUnitIncrement(int unitIncrement)
11.JScrollBar: setValue(int value)