-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgressBar.java
More file actions
49 lines (44 loc) · 1.06 KB
/
Copy pathProgressBar.java
File metadata and controls
49 lines (44 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package Swing;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class ProgressBar {
public static void main(String[] args) {
new Progress();
}
}
class Progress extends JFrame implements ActionListener{
int i=0;
JProgressBar p;
JButton b;
Timer t;
public Progress(){
p=new JProgressBar(0,20);
add(p);
b=new JButton("Click Me");
add(b);
t=new Timer(250,this);
b.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
t.start();
}
});
setLayout(new FlowLayout());
setTitle("Progress");
setVisible(true);
setSize(400,400);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
@Override
public void actionPerformed(ActionEvent e) {
i++;
p.setValue(i);
if(i>=20) {
t.stop();
new Add();
dispose();
}
}
}