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.WingButton;
028: import com.javujavu.javux.wings.WingLabel;
029: import com.javujavu.javux.wings.WingPanel;
030: import com.javujavu.javux.wings.WingTextField;
031: import com.javujavu.javux.wings.item.LabelItem;
032:
033: public class TextFieldPanel extends WingPanel {
034: public TextFieldPanel(WingSetPanel owner) {
035: this .setLayout(new GridBagLayout());
036: WingPanel panelAll, panel;
037: panelAll = new WingPanel(new BorderLayout());
038: panelAll.add(panel = new WingPanel(new GridBagLayout()),
039: BorderLayout.CENTER);
040: GridBagConstraints c = new GridBagConstraints();
041: c.insets = new Insets(10, 10, 10, 10);
042: c.anchor = GridBagConstraints.CENTER;
043: c.fill = GridBagConstraints.BOTH;
044: c.weightx = 1.0;
045: c.weighty = 1.0;
046: this .add(panelAll, c);
047:
048: String keys = "\n\nKeys:\nCtrl+A - select All\nCtrl+Insert,Ctrl+C - copy selection to clipboard\nShift+Insert,Ctrl+V - paste\nShift+Delete,Ctrl+X - cut";
049:
050: c = new GridBagConstraints();
051: c.insets = new Insets(8, 5, 8, 5);
052: c.weighty = 1.0;
053: c.gridwidth = 1;
054: c.anchor = GridBagConstraints.EAST;
055: panel.add(new WingLabel("TextField"), c);
056: c.anchor = GridBagConstraints.WEST;
057: c.gridwidth = GridBagConstraints.REMAINDER;
058: WingTextField tf;
059: panel.add(tf = new WingTextField("text field", 20), c);
060: tf.addTextListener(owner.eventTracer);
061: tf.setTooltip(new LabelItem("WingTextField\ndefault style"
062: + keys, WingSet.imgEye, LEFT, LEFT));
063:
064: c.gridwidth = 1;
065: c.anchor = GridBagConstraints.EAST;
066: panel.add(new WingLabel("right alignment"), c);
067: c.anchor = GridBagConstraints.WEST;
068: c.gridwidth = GridBagConstraints.REMAINDER;
069: panel.add(tf = new WingTextField("right alignment", 20), c);
070: tf.setHorizontalAlignment(RIGHT);
071: tf.addTextListener(owner.eventTracer);
072: tf.setTooltip(new LabelItem(
073: "WingTextField\nalignment RIGHT\ndefault style" + keys,
074: WingSet.imgEye, LEFT, RIGHT));
075:
076: c.gridwidth = 1;
077: c.anchor = GridBagConstraints.EAST;
078: panel.add(new WingLabel("password"), c);
079: c.anchor = GridBagConstraints.WEST;
080: c.gridwidth = GridBagConstraints.REMAINDER;
081: panel.add(tf = new WingTextField("password", 20), c);
082: tf.setEcho("*");
083: tf.addTextListener(owner.eventTracer);
084: tf.setTooltip(new LabelItem(
085: "WingTextField\necho char *\ndefault style" + keys,
086: WingSet.imgSilence, LEFT, RIGHT));
087:
088: c.gridwidth = 1;
089: c.anchor = GridBagConstraints.EAST;
090: panel.add(new WingLabel("custom style"), c);
091: c.anchor = GridBagConstraints.WEST;
092: c.gridwidth = GridBagConstraints.REMAINDER;
093: panel.add(tf = new WingTextField("click here ;-)", 13), c);
094: tf.setStyleId("las_vegas");
095: tf.addTextListener(owner.eventTracer);
096: tf.setTooltip(new LabelItem(
097: "WingTextField\nstyle: las_vegas (stylesheet wingsetdemo.ini)"
098: + keys, WingSet.imgBomb, RIGHT, LEFT));
099:
100: c.gridwidth = 1;
101: c.anchor = GridBagConstraints.EAST;
102: panel.add(new WingLabel("custom TopStyle"), c);
103: c.anchor = GridBagConstraints.WEST;
104: panel.add(tf = new WingTextField("custom TopStyle", 15), c);
105: tf.addTextListener(owner.eventTracer);
106: c.gridwidth = GridBagConstraints.REMAINDER;
107: WingButton b;
108: panel.add(b = new WingButton("TopStyle"), c);
109: b.setStyleId("vpopup");
110: b.setFastAction(true);
111: LabelItem tt;
112: b
113: .setTooltip(tt = new LabelItem(
114: "modify TopStyle of this WingTextField\nTopStyle is an extra style overriding stylesheet settings \ndynamically at run time\nclick buttonto change settings",
115: WingSet.imgIcon, LEFT, RIGHT));
116: new TopStyleEditor(b, tf, 20, 21, 24, 21, true);
117: tf.setTooltip(tt);
118:
119: c.gridwidth = 1;
120: c.anchor = GridBagConstraints.EAST;
121: panel.add(new WingLabel("readonly"), c);
122: c.anchor = GridBagConstraints.WEST;
123: c.gridwidth = GridBagConstraints.REMAINDER;
124: panel.add(tf = new WingTextField("readonly", 20), c);
125: tf.setEditable(false);
126: tf.addTextListener(owner.eventTracer);
127: tf.setTooltip(new LabelItem(
128: "readonly WingTextField\ndefault style" + keys,
129: WingSet.imgYawn, RIGHT, RIGHT));
130:
131: c.gridwidth = 1;
132: c.anchor = GridBagConstraints.EAST;
133: panel.add(new WingLabel("readonly password"), c);
134: c.anchor = GridBagConstraints.WEST;
135: c.gridwidth = GridBagConstraints.REMAINDER;
136: panel.add(tf = new WingTextField("readonly", 20), c);
137: tf.setEcho("*");
138: tf.setEditable(false);
139: tf.addTextListener(owner.eventTracer);
140: tf.setTooltip(new LabelItem(
141: "readonly WingTextField\necho char *\ndefault style"
142: + keys, WingSet.imgTongue, LEFT, LEFT));
143:
144: c.gridwidth = 1;
145: c.anchor = GridBagConstraints.EAST;
146: panel.add(new WingLabel("disabled"), c);
147: c.anchor = GridBagConstraints.WEST;
148: c.gridwidth = GridBagConstraints.REMAINDER;
149: panel.add(tf = new WingTextField("disabled", 20), c);
150: tf.setEnabled(false);
151: tf.addTextListener(owner.eventTracer);
152: tf.setTooltip(new LabelItem(
153: "disabled WingTextField\ndefault style" + keys,
154: WingSet.imgCrying, LEFT, LEFT));
155: }
156: }
|