Biblioteca Java - Blame information for rev 25
Subversion Repositories:
Rev | Author | Line No. | Line |
---|---|---|---|
25 | mihai | 1 | import java.util.ArrayList; |
2 | import java.util.Observable; | ||
3 | import java.util.Observer; | ||
4 | |||
5 | import javax.swing.JFrame; | ||
6 | import javax.swing.JProgressBar; | ||
7 | |||
8 | public class Window extends JFrame implements Observer { | ||
9 | ArrayList<JProgressBar> bars = new ArrayList<JProgressBar>(); | ||
10 | |||
11 | public Window(int nrThreads) { | ||
12 | setLayout(null); | ||
13 | setSize(450, 400); | ||
14 | setDefaultCloseOperation(EXIT_ON_CLOSE); | ||
15 | init(nrThreads); | ||
16 | this.setVisible(true); | ||
17 | } | ||
18 | |||
19 | private void init(int n) { | ||
20 | for (int i = 0; i < n; i++) { | ||
21 | JProgressBar pb = new JProgressBar(); | ||
22 | pb.setMaximum(1000); | ||
23 | pb.setBounds(50, (i + 1) * 30, 350, 20); | ||
24 | this.add(pb); | ||
25 | this.bars.add(pb); | ||
26 | } | ||
27 | } | ||
28 | |||
29 | public void setProgressValue(int id, int val) { | ||
30 | bars.get(id).setValue(val); | ||
31 | } | ||
32 | |||
33 | @Override | ||
34 | public void update(Observable o, Object arg) { | ||
35 | |||
36 | //System.out.println("#"); | ||
37 | Fir f = (Fir)o; | ||
38 | String n = f.getName(); | ||
39 | //int id = Integer.parseInt(n.substring(n.indexOf("-")+1))-2; | ||
40 | setProgressValue(f.id,f.c); | ||
41 | //System.out.println(f.getName()); | ||
42 | |||
43 | } | ||
44 | } |