KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > sync4j > syncclient > spds > UpdateProgressBar


1 /**
2  * Copyright (C) 2003-2005 Funambol
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  */

18
19
20 package sync4j.syncclient.spds;
21
22 import java.awt.*;
23 import java.awt.event.*;
24 import javax.swing.*;
25 import javax.swing.event.*;
26 import javax.swing.border.*;
27
28 /**
29  * This class create progress bar
30  * to display data update state
31  *
32  * @author Fabio Maggi @ Funambol
33  * $Id: UpdateProgressBar.java,v 1.2 2005/01/19 11:18:36 fabius Exp $
34  */

35 public class UpdateProgressBar extends Dialog {
36
37     //----------------------------------------------------------- Constants
38

39     private static int WIDTH = 240;
40     private static int HEIGHT = 80;
41
42     //----------------------------------------------------------- Private Data
43

44     private Dimension dim = null;
45
46     private JPanel barPanel = new JPanel();
47     private JProgressBar progressBar = new JProgressBar();
48     private JLabel labelProgressBar = new JLabel();
49
50     //----------------------------------------------------------- Constructor
51

52
53     public UpdateProgressBar(Frame parent, int maximum, String JavaDoc applicationName) {
54
55         super(parent);
56
57         labelProgressBar = new JLabel();
58
59         progressBar.setOrientation(JProgressBar.HORIZONTAL);
60
61         progressBar.setMinimum(0);
62         progressBar.setMaximum(maximum);
63
64         barPanel.add(labelProgressBar);
65         barPanel.add(progressBar);
66
67         this.add("Center",barPanel);
68         this.setSize(WIDTH,HEIGHT);
69         dim = getToolkit().getScreenSize();
70         this.setLocation(dim.width/2 - getWidth()/2, dim.height/2 - getHeight()/2);
71         this.setBackground(Color.darkGray);
72         this.setTitle(applicationName);
73
74     }
75
76     //----------------------------------------------------------- Public methods
77

78     public void setValue(int value) {
79        progressBar.setValue(value);
80     }
81
82     public void close(int value) {
83        this.setVisible(false);
84
85     }
86
87     public void Display(String JavaDoc dataStoreName) {
88
89         //new line for all dataStoreName length
90
if (dataStoreName.length() < 6) {
91             dataStoreName = dataStoreName + " ";
92         }
93
94         this.labelProgressBar.setText("Update: " + dataStoreName);
95
96         this.show();
97
98     }
99
100
101 }
Popular Tags