View Javadoc

1   package org.xmlhammer.gui.status;
2   
3   import java.awt.BorderLayout;
4   
5   import javax.swing.JLabel;
6   import javax.swing.JPanel;
7   import javax.swing.JProgressBar;
8   import javax.swing.SwingUtilities;
9   
10  public class StatusBar extends JPanel implements StatusModel {
11      private static final long serialVersionUID = 5192242308221165099L;
12  
13      protected JProgressBar progressbar = null;
14      private JLabel status = null;
15      
16      public StatusBar() {
17          super( new BorderLayout());
18          
19          status = new JLabel();
20  
21          progressbar = new JProgressBar();
22          add( status, BorderLayout.CENTER);
23          add( progressbar, BorderLayout.EAST);
24      }
25      
26      /* (non-Javadoc)
27       * @see org.xmlhammer.gui.status.StatusModel#setProgress(int, int)
28       */
29      public void setProgress( final int value, final int maximum) {
30          SwingUtilities.invokeLater( new Runnable() {
31              public void run() {
32                  progressbar.setMaximum( maximum);
33                  progressbar.setValue( value);
34              }
35          });
36      }
37  
38      /* (non-Javadoc)
39       * @see org.xmlhammer.gui.status.StatusModel#setStatus(java.lang.String)
40       */
41      public void setStatus( final String text) {
42          SwingUtilities.invokeLater( new Runnable() {
43              public void run() {
44                  status.setText( text);
45              }
46          });
47      }
48  
49      /* (non-Javadoc)
50       * @see org.xmlhammer.gui.status.StatusModel#reset()
51       */
52      public void reset() {
53          SwingUtilities.invokeLater( new Runnable() {
54              public void run() {
55                  progressbar.setValue( 0);
56                  status.setText( "Done");
57              }
58          });
59      }
60  }