01: /*
02: * Copyright 2000,2005 wingS development team.
03: *
04: * This file is part of wingS (http://wingsframework.org).
05: *
06: * wingS is free software; you can redistribute it and/or modify
07: * it under the terms of the GNU Lesser General Public License
08: * as published by the Free Software Foundation; either version 2.1
09: * of the License, or (at your option) any later version.
10: *
11: * Please see COPYING for the complete licence.
12: */
13: package wingset;
14:
15: import org.wings.*;
16:
17: import java.awt.*;
18: import java.awt.event.ActionEvent;
19: import java.awt.event.ActionListener;
20:
21: /**
22: * @author <a href="mailto:haaf@mercatis.de">Armin Haaf</a>
23: */
24: public class ProgressBarExample extends WingSetPane {
25:
26: protected SComponent createControls() {
27: return null;
28: }
29:
30: public SComponent createExample() {
31: final SButton forward1Percent = new SButton("+1");
32: final SButton forward10Percent = new SButton("+10");
33: final SButton backward1Percent = new SButton("-1");
34: final SButton backward10Percent = new SButton("-10");
35:
36: final SProgressBar progressBar = new SProgressBar(0, 100);
37:
38: final ActionListener al = new java.awt.event.ActionListener() {
39: public void actionPerformed(ActionEvent e) {
40: int valueChange = 0;
41: if (e.getSource() == forward1Percent) {
42: valueChange = 1;
43: } else if (e.getSource() == forward10Percent) {
44: valueChange = 10;
45: } else if (e.getSource() == backward1Percent) {
46: valueChange = -1;
47: } else if (e.getSource() == backward10Percent) {
48: valueChange = -10;
49: } // end of if ()
50:
51: progressBar.setValue(progressBar.getValue()
52: + valueChange);
53: }
54: };
55: forward1Percent.addActionListener(al);
56: forward10Percent.addActionListener(al);
57: backward1Percent.addActionListener(al);
58: backward10Percent.addActionListener(al);
59:
60: progressBar.setUnfilledColor(java.awt.Color.lightGray);
61: progressBar.setFilledColor(java.awt.Color.orange);
62: progressBar.setForeground(java.awt.Color.blue);
63: progressBar.setStringPainted(true);
64: progressBar.setPreferredSize(new SDimension(250,
65: SDimension.AUTO_INT));
66: progressBar.setProgressBarDimension(new SDimension(250, 12));
67:
68: progressBar.setValue(20);
69:
70: final SGridBagLayout gridBagLayout = new SGridBagLayout();
71: final SContainer panel = new SPanel(gridBagLayout);
72: panel.setPreferredSize(new SDimension("250", null));
73:
74: GridBagConstraints c0 = new GridBagConstraints();
75: GridBagConstraints c1 = new GridBagConstraints();
76: c1.gridwidth = GridBagConstraints.REMAINDER;
77: panel.add(new SLabel("<html> "), c1);
78: panel.add(progressBar, c1);
79: panel.add(backward10Percent, c0);
80: backward10Percent.setHorizontalAlignment(LEFT_ALIGN);
81: panel.add(forward10Percent, c1);
82: forward10Percent.setHorizontalAlignment(RIGHT_ALIGN);
83: panel.add(backward1Percent, c0);
84: backward1Percent.setHorizontalAlignment(LEFT_ALIGN);
85: panel.add(forward1Percent, c1);
86: forward1Percent.setHorizontalAlignment(RIGHT_ALIGN);
87:
88: return panel;
89: }
90: }
|