TextFieldPanel.java :  » Web-Framework » wingS » com » javujavu » javux » demo » Java Open Source

Java Open Source » Web Framework » wingS 
wingS » com » javujavu » javux » demo » TextFieldPanel.java
/*
*  Javu WingS - Lightweight Java Component Set
*  Copyright (c) 2005-2007 Krzysztof A. Sadlocha
*  e-mail: ksadlocha@programics.com
*
*  This library is free software; you can redistribute it and/or
*  modify it under the terms of the GNU Lesser General Public
*  License as published by the Free Software Foundation; either
*  version 2.1 of the License, or (at your option) any later version.
*
*  This library is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
*  Lesser General Public License for more details.
*
*  You should have received a copy of the GNU Lesser General Public
*  License along with this library; if not, write to the Free Software
*  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

package com.javujavu.javux.demo;

import java.awt.BorderLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import com.javujavu.javux.wings.WingButton;
import com.javujavu.javux.wings.WingLabel;
import com.javujavu.javux.wings.WingPanel;
import com.javujavu.javux.wings.WingTextField;
import com.javujavu.javux.wings.item.LabelItem;

public class TextFieldPanel extends WingPanel
{
  public TextFieldPanel(WingSetPanel owner)
  {
    this.setLayout(new GridBagLayout());
    WingPanel panelAll, panel;
    panelAll= new WingPanel(new BorderLayout());
    panelAll.add(panel= new WingPanel(
        new GridBagLayout()), BorderLayout.CENTER);
    GridBagConstraints c= new GridBagConstraints();
    c.insets= new Insets(10,10,10,10);
    c.anchor= GridBagConstraints.CENTER;
    c.fill= GridBagConstraints.BOTH;
    c.weightx= 1.0;
    c.weighty= 1.0;
    this.add(panelAll, c);

    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";


    c= new GridBagConstraints();
    c.insets= new Insets(8,5,8,5);
    c.weighty= 1.0;
    c.gridwidth= 1;
    c.anchor= GridBagConstraints.EAST;
    panel.add(new WingLabel("TextField"), c);
    c.anchor= GridBagConstraints.WEST;
    c.gridwidth= GridBagConstraints.REMAINDER;
    WingTextField tf;
    panel.add(tf= new WingTextField("text field", 20), c);
    tf.addTextListener(owner.eventTracer);
    tf.setTooltip(new LabelItem("WingTextField\ndefault style"+keys, WingSet.imgEye, LEFT, LEFT));

    
    c.gridwidth= 1;
    c.anchor= GridBagConstraints.EAST;
    panel.add(new WingLabel("right alignment"), c);
    c.anchor= GridBagConstraints.WEST;
    c.gridwidth= GridBagConstraints.REMAINDER;
    panel.add(tf= new WingTextField("right alignment", 20), c);
    tf.setHorizontalAlignment(RIGHT);
    tf.addTextListener(owner.eventTracer);
    tf.setTooltip(new LabelItem("WingTextField\nalignment RIGHT\ndefault style"+keys, WingSet.imgEye, LEFT, RIGHT));
    

    c.gridwidth= 1;
    c.anchor= GridBagConstraints.EAST;
    panel.add(new WingLabel("password"), c);
    c.anchor= GridBagConstraints.WEST;
    c.gridwidth= GridBagConstraints.REMAINDER;
    panel.add(tf= new WingTextField("password", 20), c);
    tf.setEcho("*");
    tf.addTextListener(owner.eventTracer);
    tf.setTooltip(new LabelItem("WingTextField\necho char *\ndefault style"+keys, WingSet.imgSilence, LEFT, RIGHT));

    c.gridwidth= 1;
    c.anchor= GridBagConstraints.EAST;
    panel.add(new WingLabel("custom style"), c);
    c.anchor= GridBagConstraints.WEST;
    c.gridwidth= GridBagConstraints.REMAINDER;
    panel.add(tf= new WingTextField("click here ;-)", 13), c);
    tf.setStyleId("las_vegas");
    tf.addTextListener(owner.eventTracer);
    tf.setTooltip(new LabelItem("WingTextField\nstyle: las_vegas (stylesheet wingsetdemo.ini)"+keys, WingSet.imgBomb, RIGHT, LEFT));

    c.gridwidth= 1;
    c.anchor= GridBagConstraints.EAST;
    panel.add(new WingLabel("custom TopStyle"), c);
    c.anchor= GridBagConstraints.WEST;
    panel.add(tf= new WingTextField("custom TopStyle",15), c);
    tf.addTextListener(owner.eventTracer);
    c.gridwidth= GridBagConstraints.REMAINDER;
    WingButton b;
    panel.add(b= new WingButton("TopStyle"), c);
    b.setStyleId("vpopup");
    b.setFastAction(true);
    LabelItem tt;
    b.setTooltip(tt= new LabelItem("modify TopStyle of this WingTextField\nTopStyle is an extra style overriding stylesheet settings \ndynamically at run time\nclick buttonto change settings", WingSet.imgIcon, LEFT, RIGHT));
    new TopStyleEditor(b, tf, 20,21,24,21, true);
    tf.setTooltip(tt);

    c.gridwidth= 1;
    c.anchor= GridBagConstraints.EAST;
    panel.add(new WingLabel("readonly"), c);
    c.anchor= GridBagConstraints.WEST;
    c.gridwidth= GridBagConstraints.REMAINDER;
    panel.add(tf= new WingTextField("readonly", 20), c);
    tf.setEditable(false);
    tf.addTextListener(owner.eventTracer);
    tf.setTooltip(new LabelItem("readonly WingTextField\ndefault style"+keys, WingSet.imgYawn, RIGHT, RIGHT));

    c.gridwidth= 1;
    c.anchor= GridBagConstraints.EAST;
    panel.add(new WingLabel("readonly password"), c);
    c.anchor= GridBagConstraints.WEST;
    c.gridwidth= GridBagConstraints.REMAINDER;
    panel.add(tf= new WingTextField("readonly", 20), c);
    tf.setEcho("*");
    tf.setEditable(false);
    tf.addTextListener(owner.eventTracer);
    tf.setTooltip(new LabelItem("readonly WingTextField\necho char *\ndefault style"+keys, WingSet.imgTongue, LEFT,LEFT));

    c.gridwidth= 1;
    c.anchor= GridBagConstraints.EAST;
    panel.add(new WingLabel("disabled"), c);
    c.anchor= GridBagConstraints.WEST;
    c.gridwidth= GridBagConstraints.REMAINDER;
    panel.add(tf= new WingTextField("disabled", 20), c);
    tf.setEnabled(false);
    tf.addTextListener(owner.eventTracer);
    tf.setTooltip(new LabelItem("disabled WingTextField\ndefault style"+keys, WingSet.imgCrying, LEFT,LEFT));
  }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.