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.GridLayout;
027: import java.awt.Insets;
028: import java.awt.event.KeyEvent;
029: import com.javujavu.javux.wings.WingCheckBox;
030: import com.javujavu.javux.wings.RadioGroup;
031: import com.javujavu.javux.wings.WingLabel;
032: import com.javujavu.javux.wings.WingPanel;
033: import com.javujavu.javux.wings.item.LabelItem;
034:
035: public class CheckBoxPanel extends WingPanel {
036: public CheckBoxPanel(WingSetPanel owner) {
037: this .setLayout(new GridBagLayout());
038: WingPanel panel = new WingPanel(new GridLayout(0, 2, 8, 8));
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(panel, c);
046:
047: c = new GridBagConstraints();
048: WingPanel leftTop, leftTopTitle, leftTopAll;
049: panel.add(leftTopAll = new WingPanel(new BorderLayout()));
050: leftTopAll.add(
051: leftTopTitle = new WingPanel(new BorderLayout()),
052: BorderLayout.NORTH);
053: leftTopTitle.setStyleId("border2");
054: leftTopTitle.add(new WingLabel("Look Checkbox", CENTER),
055: BorderLayout.CENTER);
056: leftTopAll.add(leftTop = new WingPanel(new GridBagLayout()),
057: BorderLayout.CENTER);
058: leftTop.setStyleId("border3");
059: c.insets = new Insets(3, 8, 0, 8);
060: c.gridwidth = GridBagConstraints.REMAINDER;
061: c.fill = GridBagConstraints.HORIZONTAL;
062: c.weightx = 1.0;
063: c.weighty = 1.0;
064:
065: String underline = "use u\u0332nicod\u0332e lo\u0332w li\u0332ne '\\u0332' to \u0332underli\u0332ne \u0332sin\u0332gle \u0332char";
066: WingCheckBox cb;
067: leftTop
068: .add(cb = new WingCheckBox(
069: "\u0332checkbox left aligned"), c);
070: cb.setShortcut(KeyEvent.VK_C, 0);
071: cb
072: .setTooltip(new LabelItem(
073: "checkbox with shortcut C\n"
074: + underline
075: + "\nhorizontal alignment LEFT\nlook CHECKBOX\ndefault style",
076: WingSet.imgEye, LEFT, RIGHT));
077: leftTop.add(cb = new WingCheckBox(
078: "\u0332checkbox center aligned"), c);
079: cb.setShortcut(KeyEvent.VK_C, KeyEvent.ALT_MASK);
080: cb
081: .setTooltip(new LabelItem(
082: "checkbox with shortcut Alt+C\n"
083: + underline
084: + "\nhorizontal alignment CENTER\nlook CHECKBOX\ndefault style",
085: WingSet.imgCrying, LEFT, RIGHT));
086: cb.setHorizontalAlignment(CENTER);
087: leftTop.add(cb = new WingCheckBox("checkbox right aligned"), c);
088: cb
089: .setTooltip(new LabelItem(
090: "checkbox\n horizontal alignment RIGHT\nlook CHECKBOX\ndefault style",
091: WingSet.imgGnash, LEFT, RIGHT));
092: cb.setHorizontalAlignment(RIGHT);
093: leftTop.add(cb = new WingCheckBox("checkbox disabled"), c);
094: cb.setTooltip(new LabelItem("disabled checkbox\ndefault style",
095: WingSet.imgLaughing, LEFT, RIGHT));
096: cb.setEnabled(false);
097: c.insets = new Insets(3, 8, 3, 8);
098: leftTop.add(cb = new WingCheckBox("text position left"), c);
099: cb.setTextPosition(LEFT);
100: cb
101: .setTooltip(new LabelItem(
102: "checkbox\ntext position LEFT\n horizontal alignment LEFT\nlook CHECKBOX\ndefault style",
103: WingSet.imgEye, LEFT, RIGHT));
104:
105: WingPanel rightTop, rightTopTitle, rightTopAll;
106: panel.add(rightTopAll = new WingPanel(new BorderLayout()));
107: rightTopAll.add(rightTopTitle = new WingPanel(
108: new BorderLayout()), BorderLayout.NORTH);
109: rightTopTitle.setStyleId("border2");
110: rightTopTitle.add(
111: new WingLabel("Look Toggle", WingLabel.CENTER),
112: BorderLayout.CENTER);
113: rightTopAll.add(rightTop = new WingPanel(new GridBagLayout()),
114: BorderLayout.CENTER);
115: rightTop.setStyleId("border3");
116:
117: c.fill = GridBagConstraints.HORIZONTAL;
118: c.gridwidth = 1;
119: c.insets = new Insets(3, 8, 0, 0);
120: rightTop
121: .add(cb = new WingCheckBox("toggle \u03321", TOGGLE), c);
122: cb.setShortcut(KeyEvent.VK_1, KeyEvent.ALT_MASK);
123: cb.setTooltip(new LabelItem(
124: "checkbox - toggle button with shortcut Alt+1\n"
125: + underline + "\nlook TOGGLE\ndefault style",
126: WingSet.imgYawn, LEFT, RIGHT));
127: c.insets = new Insets(3, 0, 0, 0);
128: rightTop
129: .add(cb = new WingCheckBox("toggle \u03322", TOGGLE), c);
130: cb.setShortcut(KeyEvent.VK_2, KeyEvent.ALT_MASK);
131: cb.setTooltip(new LabelItem(
132: "checkbox - toggle button with shortcut Alt+2\n"
133: + underline + "\nlook TOGGLE\ndefault style",
134: WingSet.imgTongue, LEFT, LEFT));
135: c.gridwidth = GridBagConstraints.REMAINDER;
136: c.insets = new Insets(3, 0, 0, 8);
137: rightTop
138: .add(cb = new WingCheckBox("toggle \u03323", TOGGLE), c);
139: cb.setShortcut(KeyEvent.VK_3, KeyEvent.ALT_MASK);
140: cb.setTooltip(new LabelItem(
141: "checkbox - toggle button with shortcut Alt+3\n"
142: + underline + "\nlook TOGGLE\ndefault style",
143: WingSet.imgSilence, RIGHT, RIGHT));
144: c.fill = GridBagConstraints.NONE;
145: c.insets = new Insets(3, 8, 0, 8);
146: WingPanel p2;
147: rightTop.add(p2 = new WingPanel(new GridLayout(1, 0, 3, 3)), c);
148: p2.add(cb = new WingCheckBox("icon and text", TOGGLE));
149: cb.setStyleId("smile");
150: cb
151: .setTooltip(new LabelItem(
152: "checkbox - toggle button with text and icon\nlook TOGGLE\nstyle: smile (stylesheet wingsetdemo.ini)",
153: WingSet.imgConfused));
154: c.gridwidth = GridBagConstraints.REMAINDER;
155: p2.add(cb = new WingCheckBox(new LabelItem("icon and text",
156: WingSet.imgTongue), TOGGLE));
157: cb
158: .setTooltip(new LabelItem(
159: "checkbox - toggle button with text and icon as label\nlook TOGGLE\ndefault style",
160: WingSet.imgConfused));
161: rightTop.add(cb = new WingCheckBox(TOGGLE), c);
162: cb.setStyleId("smile");
163: cb
164: .setTooltip(new LabelItem(
165: "checkbox - toggle button with icon\nlook TOGGLE\nstyle: smile (stylesheet wingsetdemo.ini)",
166: WingSet.imgCrying));
167: c.insets = new Insets(3, 8, 3, 8);
168: rightTop.add(cb = new WingCheckBox("toggle disabled", TOGGLE),
169: c);
170: cb
171: .setTooltip(new LabelItem(
172: "disabled checkbox - toggle button\nlook TOGGLE\ndefault style",
173: WingSet.imgCrying));
174: cb.setEnabled(false);
175:
176: WingPanel leftBottom, leftBottomTop, leftBottomAll;
177: panel.add(leftBottomAll = new WingPanel(new BorderLayout()));
178: leftBottomAll.add(leftBottomTop = new WingPanel(
179: new BorderLayout()), BorderLayout.NORTH);
180: leftBottomTop.setStyleId("border2");
181:
182: leftBottomTop.add(new WingLabel("Look Radio + RadioGroup",
183: WingLabel.CENTER), BorderLayout.CENTER);
184: leftBottomAll.add(leftBottom = new WingPanel(
185: new GridBagLayout()), BorderLayout.CENTER);
186: leftBottom.setStyleId("border3");
187:
188: c.fill = GridBagConstraints.HORIZONTAL;
189: c.insets = new Insets(3, 8, 0, 8);
190: c.gridwidth = GridBagConstraints.REMAINDER;
191:
192: RadioGroup cg = new RadioGroup();
193: leftBottom
194: .add(cb = new WingCheckBox("radio \u03321", RADIO), c);
195: cb.setShortcut(KeyEvent.VK_1, 0);
196: cb
197: .setTooltip(new LabelItem(
198: "checkbox - radio button with shortcut 1\n"
199: + underline
200: + "\ngrouped with RadioGroup\nlook RADIO\ndefault style",
201: WingSet.imgSmile, LEFT, LEFT));
202: cg.add(cb);
203: leftBottom
204: .add(cb = new WingCheckBox("radio \u03322", RADIO), c);
205: cb.setShortcut(KeyEvent.VK_2, 0);
206: cb
207: .setTooltip(new LabelItem(
208: "checkbox - radio button with shortcut 2\n"
209: + underline
210: + "\ngrouped with RadioGroup\nlook RADIO\ndefault style",
211: WingSet.imgConfused, RIGHT, LEFT));
212: cg.add(cb);
213: leftBottom
214: .add(cb = new WingCheckBox("radio \u03323", RADIO), c);
215: cb.setShortcut(KeyEvent.VK_3, 0);
216: cb
217: .setTooltip(new LabelItem(
218: "checkbox - radio button with shortcut 3\n"
219: + underline
220: + "\ngrouped with RadioGroup\nlook RADIO\ndefault style",
221: WingSet.imgAngel, RIGHT, RIGHT));
222: cg.add(cb);
223: c.insets = new Insets(3, 8, 3, 8);
224: leftBottom.add(cb = new WingCheckBox("radio disabled", RADIO),
225: c);
226: cb
227: .setTooltip(new LabelItem(
228: "disabled checkbox - radio button\nlook RADIO\ndefault style",
229: WingSet.imgSmile));
230: cb.setEnabled(false);
231:
232: WingPanel rightBottom, rightBottomTitle, rightBottomAll;
233: panel.add(rightBottomAll = new WingPanel(new BorderLayout()));
234: rightBottomAll.add(rightBottomTitle = new WingPanel(
235: new BorderLayout()), BorderLayout.NORTH);
236: rightBottomTitle.setStyleId("border2");
237: rightBottomTitle.add(new WingLabel("Mixed + RadioGroup",
238: WingLabel.CENTER), BorderLayout.CENTER);
239: rightBottomAll.add(rightBottom = new WingPanel(
240: new GridBagLayout()), BorderLayout.CENTER);
241: rightBottom.setStyleId("border3");
242:
243: cg = new RadioGroup();
244: c.insets = new Insets(3, 8, 0, 8);
245: c.fill = GridBagConstraints.HORIZONTAL;
246: rightBottom.add(new WingLabel(), c);
247: rightBottom.add(cb = new WingCheckBox("custom style checkbox",
248: CHECKBOX), c);
249: cb.setStyleId("custom_check");
250: cb
251: .setTooltip(new LabelItem(
252: "checkbox\ngrouped with RadioGroup\nlook CHECKBOX\nstyle: custom_check (stylesheet wingsetdemo.ini)",
253: WingSet.imgBomb, LEFT, LEFT));
254: cg.add(cb);
255: rightBottom.add(cb = new WingCheckBox("multiline\ntext radio",
256: RADIO), c);
257: cb
258: .setTooltip(new LabelItem(
259: "checkbox with multiline text\nuse '\\n' to break line\ngrouped with RadioGroup\nlook RADIO\ndefault style",
260: WingSet.imgEye, LEFT, RIGHT));
261: cg.add(cb);
262: rightBottom.add(cb = new WingCheckBox("toggle 3", TOGGLE), c);
263: cb
264: .setTooltip(new LabelItem(
265: "checkbox - toggle button\ngrouped with RadioGroup\nlook TOGGLE\ndefault style",
266: WingSet.imgScared, RIGHT, RIGHT));
267: cg.add(cb);
268: c.insets = new Insets(3, 8, 3, 8);
269: rightBottom.add(cb = new WingCheckBox("checkbox 1"), c);
270: cb
271: .setTooltip(new LabelItem(
272: "checkbox\ngrouped with RadioGroup\nlook CHECKBOX\ndefault style",
273: WingSet.imgUgly, RIGHT, LEFT));
274: cg.add(cb);
275: }
276: }
|