-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgressBarDemo.java
More file actions
37 lines (30 loc) · 881 Bytes
/
Copy pathProgressBarDemo.java
File metadata and controls
37 lines (30 loc) · 881 Bytes
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
import java.awt.*;
import javax.swing.*;
public class ProgressBarDemo {
JFrame frame = new JFrame();
JProgressBar bar = new JProgressBar();
//this is just creating the frame for the progressbar
public ProgressBarDemo(){
bar.setValue(0);
bar.setBounds(0,0,420, 100);
frame.add(bar);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(420, 100);
frame.setLayout(null);
frame.setVisible(true);
fill();
}
//this is the actual code for the progress bar
public void fill(){
int counter = 0;
while(counter<=100) {
bar.setValue(counter);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
counter += 10;
}
}
}