Java Swing Tutorial - Java DefaultBoundedRangeModel .getListeners (Class <T> listenerType)


DefaultBoundedRangeModel.getListeners(Class <T> listenerType) has the following syntax.

public<T extends EventListener>T[] getListeners(Class<T> listenerType)


In the following code shows how to use DefaultBoundedRangeModel.getListeners(Class <T> listenerType) method.

/*from  ww  w  . j a v  a2s  .  c o m*/

import javax.swing.DefaultBoundedRangeModel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

public class Main {
  public static void main(String args[]) {
    try {
      DefaultBoundedRangeModel model = new DefaultBoundedRangeModel();
      ChangeListener myListener = new MyChangeListener();
      ChangeListener[] lis = model.getChangeListeners();

    } catch (Exception e) {

class MyChangeListener implements ChangeListener {
  public void stateChanged(ChangeEvent e) {
    System.out.println("A ChangeEvent has been fired!");