WaitingDialog: do not allow close and dispose when needed
[fanfix.git] / ui / test / ProgressBarManualTest.java
... / ...
CommitLineData
1package be.nikiroo.utils.ui.test;
2
3import java.awt.BorderLayout;
4import java.awt.event.ActionEvent;
5import java.awt.event.ActionListener;
6
7import javax.swing.JButton;
8import javax.swing.JFrame;
9
10import be.nikiroo.utils.Progress;
11import be.nikiroo.utils.ui.ProgressBar;
12
13public class ProgressBarManualTest extends JFrame {
14 private static final long serialVersionUID = 1L;
15 private int i = 0;
16
17 public ProgressBarManualTest() {
18 final ProgressBar bar = new ProgressBar();
19 final Progress pg = new Progress("name");
20 final Progress pg2 = new Progress("second level", 0, 2);
21 final Progress pg3 = new Progress("third level");
22
23 setLayout(new BorderLayout());
24 this.add(bar, BorderLayout.SOUTH);
25
26 final JButton b = new JButton("Set pg to 10%");
27 b.addActionListener(new ActionListener() {
28 @Override
29 public void actionPerformed(ActionEvent e) {
30 switch (i) {
31 case 0:
32 pg.setProgress(10);
33 pg2.setProgress(0);
34 b.setText("Set pg to 20%");
35 break;
36 case 1:
37 pg.setProgress(20);
38 b.setText("Add pg2 (0-2)");
39 break;
40 case 2:
41 pg.addProgress(pg2, 80);
42 pg2.setProgress(0);
43 b.setText("Add pg3 (0-100)");
44 break;
45 case 3:
46 pg2.addProgress(pg3, 2);
47 pg3.setProgress(0);
48 b.setText("Set pg3 to 10%");
49 break;
50 case 4:
51 pg3.setProgress(10);
52 b.setText("Set pg3 to 20%");
53 break;
54 case 5:
55 pg3.setProgress(20);
56 b.setText("Set pg3 to 60%");
57 break;
58 case 6:
59 pg3.setProgress(60);
60 b.setText("Set pg3 to 100%");
61 break;
62 case 7:
63 pg3.setProgress(100);
64 b.setText("[done]");
65 break;
66 }
67
68 i++;
69 }
70 });
71 this.add(b, BorderLayout.CENTER);
72
73 setSize(800, 600);
74 setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
75
76 bar.setProgress(pg);
77 }
78
79 public static void main(String[] args) {
80 new ProgressBarManualTest().setVisible(true);
81 }
82}