-
Notifications
You must be signed in to change notification settings - Fork 0
/
Loading.java
63 lines (53 loc) · 1.63 KB
/
Loading.java
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package travelnow;
import javax.swing.*;
import java.awt.*;
public class Loading extends JFrame implements Runnable{
JProgressBar p;
String username;
Thread t;
public void run(){
try{
for(int i=1;i<=100;i++){
int x=p.getMaximum();
int y=p.getValue();
if(y<x){
p.setValue(p.getValue()+1);
}if(i==100){
setVisible(false);
new Dashboard(username).setVisible(true);
}
Thread.sleep(60);
}
}catch(Exception e){
}
}
Loading(String user){
username=user;
t=new Thread(this);
setBounds(400,250,650,400);
getContentPane().setBackground(Color.WHITE);
setLayout(null);
JLabel l1=new JLabel("Welcome to TravelNow");
l1.setBounds(130,20,600,40);
l1.setFont(new Font("Raleway",Font.BOLD,35));
add(l1);
p=new JProgressBar();
p.setStringPainted(true);
p.setBounds(180, 130, 300, 25);
add(p);
JLabel l2=new JLabel("Loading..");
l2.setBounds(290,150,600,40);
l2.setFont(new Font("Raleway",Font.BOLD,14));
l2.setForeground(Color.red);
add(l2);
t.start();
}
public static void main(String[] args){
new Loading("").setVisible(true);
}
}