JProgressBar: addChangeListener(ChangeListener l) : JProgressBar « javax.swing « Java by API






JProgressBar: addChangeListener(ChangeListener l)

  

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

public class Main {
  public static void main(String[] argv) throws Exception {
    int minimum = 0;
    int maximum = 100;
    JProgressBar progress = new JProgressBar(minimum, maximum);

    progress.addChangeListener(new ChangeListener() {
      public void stateChanged(ChangeEvent evt) {
        JProgressBar comp = (JProgressBar) evt.getSource();
        int value = comp.getValue();
        int min = comp.getMinimum();
        int max = comp.getMaximum();
      }
    });
  }
}

   
    
  








Related examples in the same category

1.JProgressBar.VERTICAL
2.new JProgressBar(int min, int max)
3.new JProgressBar(int orient, int min, int max)
4.JProgressBar: getMaximum()
5.JProgressBar: getMinimum()
6.JProgressBar: getValue()
7.JProgressBar: setBorder(Border b)
8.JProgressBar: setBorderPainted(boolean b)
9.JProgressBar: setIndeterminate(boolean newValue)
10.JProgressBar: setMaximum(int n)
11.JProgressBar: setMinimum(int n)
12.JProgressBar: setStringPainted(boolean b)
13.JProgressBar: setValue(int v)