001: /*
002: * Javu WingS - Lightweight Java Component Set
003: * Copyright (c) 2005-2007 Krzysztof A. Sadlocha
004: * e-mail: ksadlocha@programics.com
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or (at your option) any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
019: */
020:
021: package com.javujavu.javux.demo;
022:
023: import java.awt.BorderLayout;
024: import java.awt.GridBagConstraints;
025: import java.awt.GridBagLayout;
026: import java.awt.Insets;
027: import com.javujavu.javux.wings.WingLabel;
028: import com.javujavu.javux.wings.WingPanel;
029: import com.javujavu.javux.wings.WingSpinner;
030: import com.javujavu.javux.wings.item.LabelItem;
031:
032: public class SpinnerPanel extends WingPanel {
033: public SpinnerPanel(WingSetPanel owner) {
034: this .setLayout(new GridBagLayout());
035: WingPanel panelAll, panel;
036: panelAll = new WingPanel(new BorderLayout());
037: panelAll.add(panel = new WingPanel(new GridBagLayout()),
038: BorderLayout.CENTER);
039: GridBagConstraints c = new GridBagConstraints();
040: c.insets = new Insets(10, 10, 10, 10);
041: c.anchor = GridBagConstraints.CENTER;
042: c.fill = GridBagConstraints.BOTH;
043: c.weightx = 1.0;
044: c.weighty = 1.0;
045: this .add(panelAll, c);
046:
047: String shortcuts = "Scrolling with MOUSE WHEEL works on Java>=1.4\nKeys:\nUp - increase value\nDown - decrease value";
048:
049: c = new GridBagConstraints();
050: c.insets = new Insets(8, 5, 8, 5);
051: c.weighty = 1.0;
052: c.gridwidth = 1;
053: c.anchor = GridBagConstraints.EAST;
054: panel.add(new WingLabel("numeric"), c);
055: c.anchor = GridBagConstraints.WEST;
056: WingSpinner sp;
057: panel.add(sp = new WingSpinner(), c);
058: sp.setTooltip(new LabelItem(
059: "WingSpinner\nalignment LEFT\ndefault style\n\n"
060: + shortcuts, WingSet.imgEye, LEFT, LEFT));
061: c.gridwidth = GridBagConstraints.REMAINDER;
062: panel.add(sp = new WingSpinner(), c);
063: sp.setTooltip(new LabelItem(
064: "WingSpinner\nalignment RIGHT\ndefault style\n\n"
065: + shortcuts, WingSet.imgEye, LEFT, LEFT));
066: sp.setHorizontalAlignment(RIGHT);
067:
068: c.gridwidth = 1;
069: c.anchor = GridBagConstraints.EAST;
070: panel.add(new WingLabel("exponential"), c);
071: c.anchor = GridBagConstraints.WEST;
072: panel.add(sp = new WingSpinner(), c);
073: sp.addRange(0, 9, 1);
074: sp.addRange(10, 90, 10);
075: sp.addRange(100, 900, 100);
076: sp.addRange(1000, 9000, 1000);
077: sp.addEnum(10000, "infinity");
078: sp.setTooltip(new LabelItem(
079: "WingSpinner\nalignment LEFT\ndefault style\n\n"
080: + shortcuts, WingSet.imgUgly, LEFT, RIGHT));
081: c.gridwidth = GridBagConstraints.REMAINDER;
082: panel.add(sp = new WingSpinner(), c);
083: sp.addRange(0, 9, 1);
084: sp.addRange(10, 90, 10);
085: sp.addRange(100, 900, 100);
086: sp.addRange(1000, 9000, 1000);
087: sp.addEnum(10000, "infinity");
088: sp.setHorizontalAlignment(RIGHT);
089: sp.setTooltip(new LabelItem(
090: "WingSpinner\nalignment RIGHT\ndefault style\n\n"
091: + shortcuts, WingSet.imgUgly, LEFT, RIGHT));
092:
093: c.gridwidth = 1;
094: c.anchor = GridBagConstraints.EAST;
095: panel.add(new WingLabel("roman"), c);
096: c.anchor = GridBagConstraints.WEST;
097: panel.add(sp = new WingSpinner(), c);
098: sp.addEnum(1, "I");
099: sp.addEnum(2, "II");
100: sp.addEnum(3, "III");
101: sp.addEnum(4, "IV");
102: sp.addEnum(5, "V");
103: sp.addEnum(6, "VI");
104: sp.addEnum(7, "VII");
105: sp.addEnum(8, "VIII");
106: sp.addEnum(9, "IX");
107: sp.addEnum(10, "X");
108: sp.setValue(1);
109: sp.setTooltip(new LabelItem(
110: "WingSpinner\nalignment LEFT\ndefault style\n\n"
111: + shortcuts, WingSet.imgCrying, RIGHT, LEFT));
112: c.gridwidth = GridBagConstraints.REMAINDER;
113: panel.add(sp = new WingSpinner(), c);
114: sp.addEnum(1, "I");
115: sp.addEnum(2, "II");
116: sp.addEnum(3, "III");
117: sp.addEnum(4, "IV");
118: sp.addEnum(5, "V");
119: sp.addEnum(6, "VI");
120: sp.addEnum(7, "VII");
121: sp.addEnum(8, "VIII");
122: sp.addEnum(9, "IX");
123: sp.addEnum(10, "X");
124: sp.setValue(1);
125: sp.setHorizontalAlignment(RIGHT);
126: sp.setTooltip(new LabelItem(
127: "WingSpinner\nalignment RIGHT\ndefault style\n\n"
128: + shortcuts, WingSet.imgCrying, RIGHT, LEFT));
129:
130: c.gridwidth = 1;
131: c.anchor = GridBagConstraints.EAST;
132: panel.add(new WingLabel("text"), c);
133: c.anchor = GridBagConstraints.WEST;
134: panel.add(sp = new WingSpinner(), c);
135: sp.addEnum(1, "one");
136: sp.addEnum(2, "two");
137: sp.addEnum(3, "three");
138: sp.addEnum(4, "four");
139: sp.addEnum(5, "five");
140: sp.addEnum(6, "six");
141: sp.addEnum(7, "seven");
142: sp.addEnum(8, "eight");
143: sp.addEnum(9, "nine");
144: sp.addEnum(10, "ten");
145: sp.setValue(1);
146: sp.setTooltip(new LabelItem(
147: "WingSpinner\nalignment LEFT\ndefault style\n\n"
148: + shortcuts, WingSet.imgSilence, LEFT, LEFT));
149: c.gridwidth = GridBagConstraints.REMAINDER;
150: panel.add(sp = new WingSpinner(), c);
151: sp.addEnum(1, "one");
152: sp.addEnum(2, "two");
153: sp.addEnum(3, "three");
154: sp.addEnum(4, "four");
155: sp.addEnum(5, "five");
156: sp.addEnum(6, "six");
157: sp.addEnum(7, "seven");
158: sp.addEnum(8, "eight");
159: sp.addEnum(9, "nine");
160: sp.addEnum(10, "ten");
161: sp.setValue(1);
162: sp.setHorizontalAlignment(RIGHT);
163: sp.setTooltip(new LabelItem(
164: "WingSpinner\nalignment RIGHT\ndefault style\n\n"
165: + shortcuts, WingSet.imgSilence, LEFT, LEFT));
166:
167: c.gridwidth = 1;
168: c.anchor = GridBagConstraints.EAST;
169: panel.add(new WingLabel("mixed"), c);
170: c.anchor = GridBagConstraints.WEST;
171: panel.add(sp = new WingSpinner(), c);
172: sp.addEnum(-1, "lest than zero");
173: sp.addEnum(0, "zero");
174: sp.addRange(1, 10, 1);
175: sp.addEnum(11, "over ten");
176: sp.setValue(1);
177: sp.setTooltip(new LabelItem(
178: "WingSpinner\nalignment LEFT\ndefault style\n\n"
179: + shortcuts, WingSet.imgSmile, RIGHT, RIGHT));
180: c.gridwidth = GridBagConstraints.REMAINDER;
181: panel.add(sp = new WingSpinner(), c);
182: sp.addEnum(-1, "lest than zero");
183: sp.addEnum(0, "zero");
184: sp.addRange(1, 10, 1);
185: sp.addEnum(11, "over ten");
186: sp.setValue(1);
187: sp.setHorizontalAlignment(RIGHT);
188: sp.setTooltip(new LabelItem(
189: "WingSpinner\nalignment RIGHT\ndefault style\n\n"
190: + shortcuts, WingSet.imgSmile, RIGHT, RIGHT));
191:
192: c.gridwidth = 1;
193: c.anchor = GridBagConstraints.EAST;
194: panel.add(new WingLabel("custom style"), c);
195: c.anchor = GridBagConstraints.WEST;
196: panel.add(sp = new WingSpinner(), c);
197: sp.setStyleId("las_vegas");
198: sp
199: .setTooltip(new LabelItem(
200: "WingSpinner\nalignment LEFT\nstyle: las_vegas (stylesheet wingsetdemo.ini)\n\n"
201: + shortcuts, WingSet.imgGnash, LEFT,
202: RIGHT));
203: c.gridwidth = GridBagConstraints.REMAINDER;
204: panel.add(sp = new WingSpinner(), c);
205: sp.setStyleId("las_vegas");
206: sp.setHorizontalAlignment(RIGHT);
207: sp
208: .setTooltip(new LabelItem(
209: "WingSpinner\nalignment RIGHT\nstyle: las_vegas (stylesheet wingsetdemo.ini)\n\n"
210: + shortcuts, WingSet.imgGnash, LEFT,
211: RIGHT));
212:
213: c.gridwidth = 1;
214: c.anchor = GridBagConstraints.EAST;
215: panel.add(new WingLabel("disabled"), c);
216: c.anchor = GridBagConstraints.WEST;
217: panel.add(sp = new WingSpinner(), c);
218: sp.setEnabled(false);
219: sp.setTooltip(new LabelItem(
220: "disabled WingSpinner\nalignment LEFT\ndefault style\n\n"
221: + shortcuts, WingSet.imgTired, RIGHT, LEFT));
222: c.gridwidth = GridBagConstraints.REMAINDER;
223: panel.add(sp = new WingSpinner(), c);
224: sp.setEnabled(false);
225: sp.setHorizontalAlignment(RIGHT);
226: sp.setTooltip(new LabelItem(
227: "disabled WingSpinner\nalignment RIGHT\ndefault style\n\n"
228: + shortcuts, WingSet.imgTired, RIGHT, LEFT));
229: }
230: }
|