Commit | Line | Data |
---|---|---|
80500544 | 1 | package be.nikiroo.utils.ui.test; |
88b36f83 NR |
2 | |
3 | import java.awt.BorderLayout; | |
4 | import java.awt.event.ActionEvent; | |
5 | import java.awt.event.ActionListener; | |
6 | ||
7 | import javax.swing.JButton; | |
8 | import javax.swing.JFrame; | |
9 | ||
10 | import be.nikiroo.utils.Progress; | |
11 | import be.nikiroo.utils.ui.ProgressBar; | |
12 | ||
13 | public 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"); | |
11f9e5f3 NR |
20 | final Progress pg2 = new Progress("second level", 0, 2); |
21 | final Progress pg3 = new Progress("third level"); | |
88b36f83 NR |
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() { | |
cd0c27d2 | 28 | @Override |
88b36f83 NR |
29 | public void actionPerformed(ActionEvent e) { |
30 | switch (i) { | |
31 | case 0: | |
32 | pg.setProgress(10); | |
2998b78a | 33 | pg2.setProgress(0); |
88b36f83 NR |
34 | b.setText("Set pg to 20%"); |
35 | break; | |
36 | case 1: | |
37 | pg.setProgress(20); | |
11f9e5f3 | 38 | b.setText("Add pg2 (0-2)"); |
88b36f83 NR |
39 | break; |
40 | case 2: | |
41 | pg.addProgress(pg2, 80); | |
42 | pg2.setProgress(0); | |
11f9e5f3 | 43 | b.setText("Add pg3 (0-100)"); |
88b36f83 NR |
44 | break; |
45 | case 3: | |
11f9e5f3 NR |
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]"); | |
88b36f83 NR |
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 | } |