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.Color;
025: import java.awt.GridBagConstraints;
026: import java.awt.GridBagLayout;
027: import java.awt.GridLayout;
028: import java.awt.Insets;
029: import com.javujavu.javux.wings.WingButton;
030: import com.javujavu.javux.wings.WingCheckBox;
031: import com.javujavu.javux.wings.WingCombo;
032: import com.javujavu.javux.wings.WingLabel;
033: import com.javujavu.javux.wings.WingMenu;
034: import com.javujavu.javux.wings.WingMenuItem;
035: import com.javujavu.javux.wings.WingPanel;
036: import com.javujavu.javux.wings.WingSpinner;
037: import com.javujavu.javux.wings.WingTextPane;
038: import com.javujavu.javux.wings.extra.ColorItem;
039: import com.javujavu.javux.wings.item.LabelItem;
040:
041: public class TooltipPanel extends WingPanel {
042: public TooltipPanel(WingSetPanel owner) {
043: this .setLayout(new GridBagLayout());
044: WingPanel panel = new WingPanel(new GridLayout(0, 2, 8, 8));
045: GridBagConstraints c = new GridBagConstraints();
046: c.insets = new Insets(10, 10, 10, 10);
047: c.anchor = GridBagConstraints.CENTER;
048: c.fill = GridBagConstraints.BOTH;
049: c.weightx = 1.0;
050: c.weighty = 1.0;
051: this .add(panel, c);
052:
053: WingPanel left, leftAll;
054: panel.add(leftAll = new WingPanel(new BorderLayout()));
055: leftAll.add(left = new WingPanel(new GridBagLayout()),
056: BorderLayout.CENTER);
057: left.setStyleId("border1");
058:
059: c = new GridBagConstraints();
060: c.insets = new Insets(3, 3, 0, 3);
061: c.gridwidth = GridBagConstraints.REMAINDER;
062: c.weighty = 1.0;
063: c.weightx = 1.0;
064: WingButton b;
065: left.add(b = new WingButton(), c);
066: b.setStyleId("smile");
067: b.setTooltip(WingSet.imgSmile);
068: left.add(b = new WingButton("text and icon"), c);
069: b.setStyleId("smile");
070: b.setTooltip(new LabelItem("text and icon", WingSet.imgSmile));
071: left.add(b = new WingButton("multiline\ntext\nand icon"), c);
072: b.setStyleId("smile");
073: b.setTooltip(new LabelItem("multiline\ntext\nand icon",
074: WingSet.imgSmile));
075: left.add(b = new WingButton("disabled"), c);
076: b.setTooltip("disabled has tooltip");
077: b.setEnabled(false);
078: left.add(
079: b = new WingButton(new LabelItem(
080: "tooltip with\ncustom item renderer",
081: WingSet.imgSeek)), c);
082: b.setTooltip(new ColorItem(
083: "tooltip with\ncustom item renderer", Color.magenta));
084: left.add(b = new WingButton(new LabelItem(
085: "transparent tooltip", WingSet.imgGlasses)), c);
086: WingLabel l;
087: b
088: .setTooltip(l = new WingLabel(
089: "Transparent tooltip\nstyle: alpha_tooltip (stylesheet wingsetdemo.ini)\n\nTransparency works\non Java >= 1.2",
090: LEFT));
091: l.setStyleId("alpha_tooltip");
092: left.add(b = new WingButton(new LabelItem("more transparent",
093: WingSet.imgEye)), c);
094: b
095: .setTooltip(l = new WingLabel(
096: "Transparent tooltip\nstyle: alpha_tooltip2 (stylesheet wingsetdemo.ini)\n\nTransparency works\non Java >= 1.2",
097: LEFT));
098: l.setStyleId("alpha_tooltip2");
099: // l.setTextPosition(LEFT);
100: left.add(b = new WingButton(new LabelItem("animated tooltip",
101: WingSet.imgAnim)), c);
102: b
103: .setTooltip(new LabelItem("animated tooltip",
104: WingSet.imgAnim));
105: c.insets = new Insets(3, 3, 3, 3);
106: left.add(b = new WingButton(new LabelItem("extreme tooltip",
107: WingSet.imgBomb)), c);
108: WingTextPane ta = new WingTextPane();
109: TextPanePanel.setText(ta, 6);
110: b.setTooltip(ta);
111:
112: WingPanel right;
113: panel.add(right = new WingPanel(new GridBagLayout()));
114: right.setStyleId("border1");
115:
116: c.insets = new Insets(3, 3, 0, 3);
117: right.add(l = new WingLabel("Label with tooltip"), c);
118: l.setTooltip("Label with tooltip");
119: WingCombo cb;
120: right.add(cb = new WingCombo(), c);
121: cb.addItem("Combo with tooltip");
122: cb.setTooltip("Combo with tooltip");
123: WingCheckBox cbx;
124: right.add(cbx = new WingCheckBox("Checkbox with tooltip"), c);
125: cbx.setTooltip("Checkbox with tooltip");
126: WingSpinner sp;
127: right.add(sp = new WingSpinner(), c);
128: sp.addEnum(0, "Spinner with tooltip");
129: sp.addRange(1, 10, 1);
130: sp.setValue(0);
131: sp.setTooltip("Spinner with tooltip");
132: c.fill = GridBagConstraints.HORIZONTAL;
133: WingMenu m;
134: right.add(m = new WingMenu(HORIZONTAL), c);
135: m.setTooltip("Menu with tooltips");
136: WingMenuItem mi;
137: WingMenu m2;
138: m.addSeparator();
139: m.add(m2 = new WingMenu("Menu"));
140: m2.setTooltip("Menu");
141: m2.add(mi = new WingMenuItem("Submenu"));
142: mi.setTooltip("Submenu");
143: m2.add(mi = new WingMenuItem("with"));
144: mi.setTooltip("with");
145: m2.add(mi = new WingMenuItem("tootlips"));
146: mi.setTooltip("tootlips");
147: m.add(m2 = new WingMenu("with"));
148: m2.setTooltip("with");
149: m2.add(mi = new WingMenuItem("with"));
150: mi.setTooltip("with");
151: m.add(m2 = new WingMenu("tootlips"));
152: m2.setTooltip("tootlips");
153: m2.add(mi = new WingMenuItem("tootlips"));
154: mi.setTooltip("tootlips");
155: m.addSeparator();
156: m.add(mi = new WingMenuItem("why", CHECKBOX));
157: mi.setSelected(true);
158: mi.setTooltip("why");
159: m.add(mi = new WingMenuItem("not", RADIO));
160: mi.setSelected(true);
161: mi.setTooltip("not");
162: m.addSeparator();
163:
164: c.fill = GridBagConstraints.BOTH;
165: c.insets = new Insets(10, 10, 10, 10);
166: WingPanel p2;
167: right.add(p2 = new WingPanel(new GridBagLayout()), c);
168: p2.setStyleId("border1");
169: p2.add(l = new WingLabel("Panel with tooltip"));
170: p2.setTooltip("Panel with tooltip");
171: l.setTooltip("Panel with tooltip");
172:
173: left.setTooltip("this panel has tooltip");
174: right.setTooltip("this panel has tooltip");
175:
176: }
177:
178: }
|