List of usage examples for javax.swing JProgressBar addChangeListener
public void addChangeListener(ChangeListener l)
ChangeListener
to the progress bar. From source file:Main.java
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(); }/* w w w . ja va 2 s . c o m*/ }); }
From source file:BoundedChangeListener.java
public static void main(String args[]) throws Exception { JFrame frame = new JFrame("Stepping Progress"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final JProgressBar aJProgressBar = new JProgressBar(JProgressBar.VERTICAL); aJProgressBar.setStringPainted(true); aJProgressBar.addChangeListener(new BoundedChangeListener()); for (int i = 0; i < 10; i++) { aJProgressBar.setValue(i++);/*from w w w. j av a 2s .c o m*/ Thread.sleep(100); } frame.add(aJProgressBar, BorderLayout.NORTH); frame.setSize(300, 200); frame.setVisible(true); }