Package swing.login

Source Code of swing.login.LoginForm

/*
* LoginForm.java
*
* Created on 2009. oktober 20., 13:32
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/

package swing.login;

import java.awt.FlowLayout;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.util.EventObject;
import java.util.Vector;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import swing.button.OpenFormButton;
import swing.form.Form;
import swing.form.FormUtil;
import swing.jip.JipForm;
import swing.panel.PasswordFieldPanel;
import swing.panel.TextFieldPanel;
import system.ugyfel.UgyfelUtil;
import system.util.EventMulticaster;
import system.util.Login;

/**
*
* @author laci
*/
public class LoginForm extends Form{
 
// <editor-fold defaultstate="collapsed" desc="Konstruktor">
  /** Creates a new instance of LoginForm */
  public LoginForm(Login login) {
    super(login);
    initialize();
  }
// </editor-fold>
 
// <editor-fold defaultstate="collapsed" desc="Inicializalas">
 
  // TODO: getFocusOrder hasznalata a fokusz beallitasara
  public void initialize() {
    setContentTitle(getFormResource("LoginForm.ContentTitle"));
    initialize(getFormResource("LoginForm.Name"), getFormResource("LoginForm.Title"), getMainFrame(), true, null);
  }
 
// </editor-fold>
   
// <editor-fold defaultstate="collapsed" desc="Fokusz order">
   
  protected Vector getFocusOrder() {
    return new Vector();
  }
   
// </editor-fold>
 
// <editor-fold defaultstate="collapsed" desc="enabler">

  /** Formon levo mezok tiltasara, engedelyezesere szolgal. */
  @Override
  protected void enabler(EventObject e) {
   
  }
 
// </editor-fold>
 
// <editor-fold defaultstate="collapsed" desc="kitolt">
 
  /** Kepernyo kitoltese */
  protected void fill() {
    getLoginNevPanel().setText(null);
    getPasswordPanel().setText(null);
  }
// </editor-fold>
 
// <editor-fold defaultstate="collapsed" desc="reszet">
 
  /** Kepernyo torlese */
  protected void reset() {
    fill();
  }
 
// </editor-fold>
 
// <editor-fold defaultstate="collapsed" desc="RUN">
 
  public boolean run() {
    getCancelButton().addActionListener(getExitListener());
   
    return activate();
  }
  // TODO listenereket csin�lni a kil�p�shez ... ha deactive akkor deactivot h�v ha exit akkor system.exit-et
 
// </editor-fold>
 
// <editor-fold defaultstate="collapsed" desc="TESZT">
 
    public static void main(String[] args) {
        LoginForm form = new LoginForm(new Login());
    System.out.println(form.run());
   
    }
 
// </editor-fold>
 
// <editor-fold defaultstate="collapsed" desc="LoginNev">
 
  private TextFieldPanel loginNev;
 
  public TextFieldPanel getLoginNevPanel() {
    if (loginNev == null) {
      loginNev = createLoginNevPanel();
    }

    return loginNev;
  }
 
  protected TextFieldPanel createLoginNevPanel() {
    TextFieldPanel temp = new TextFieldPanel(getLogin(),getFormResource("LoginForm.LoginNevCimke"));

    return temp;
  }
 
  protected String getLoginNev() {
    return getLoginNevPanel().getText();
  }
 
// </editor-fold>
 
// <editor-fold defaultstate="collapsed" desc="jelszo">
 
  private PasswordFieldPanel password;
 
  public PasswordFieldPanel getPasswordPanel() {
    if (password == null) {
      password = createPasswordPanel();
    }

    return password;
  }
 
  protected PasswordFieldPanel createPasswordPanel() {
    PasswordFieldPanel temp = new PasswordFieldPanel(getLogin(),getFormResource("LoginForm.PasswordCimke"));
    /// Ha az utols� mez�n�l enter �t�nk �s minden mez� helyesen van kit�ltve akkor bel�p�s.
    temp.addFocusListener(
      new FocusListener() {
        public void focusGained(FocusEvent e) {
        }

        public void focusLost(FocusEvent e) {
          if (valid()) {
            getOkButton().doClick();
          }
        }
      });

    return temp;
  }
 
  public String getPassword() {
    return getPasswordPanel().getText();
  }
 
// </editor-fold>
 
// <editor-fold defaultstate="collapsed" desc="createOkButton">
 
  protected OpenFormButton createOkButton() {
    OpenFormButton temp = super.createOkButton();
    // TODO: login r�sz meg�r�sa
    JipForm form = new JipForm(getLogin());
    form.setParentForm(this);
    temp.setForm(form);
    temp.setTipus(OpenFormButton.DEAVTICE_PARENT_FORM);
        temp.addActionListener(new EventMulticaster(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
          Integer tkod = UgyfelUtil.getTkodByLogin(getLogin(),getLoginNev(),getPassword());
          getLogin().setUser(tkod);
        }
      },temp.getOpenListener()));
   
    return temp;
  }
 
// </editor-fold>

// <editor-fold defaultstate="collapsed" desc="createMainFrame">

  @Override
  protected JScrollPane createMainFrame() {
    JScrollPane temp = super.createMainFrame();
    JPanel foPanel = new JPanel(new GridBagLayout());
    JPanel gombPanel = new JPanel(new FlowLayout());
    getContent().add(getContentTitle(),FormUtil.newGBConstraints(0, 0, 1, 1, FormUtil.ANCHOR_CENTER, FormUtil.FILL_NONE, null));
    getContent().add(foPanel,FormUtil.newGBConstraints(0, 1, 1, 1, FormUtil.ANCHOR_WEST, FormUtil.FILL_NONE, null));
    foPanel.add(getLoginNevPanel(),FormUtil.newGBConstraints(0, 0, 1, 1, FormUtil.ANCHOR_CENTER, FormUtil.FILL_NONE, null));
    foPanel.add(getPasswordPanel(),FormUtil.newGBConstraints(0, 1, 1, 1, FormUtil.ANCHOR_CENTER, FormUtil.FILL_NONE, null));
   
    getContent().add(gombPanel,FormUtil.newGBConstraints(0, 2, 1, 1, FormUtil.ANCHOR_CENTER, FormUtil.FILL_NONE, null));
    gombPanel.add(getOkButton());
    gombPanel.add(getCancelButton());

    return temp;
  }

// </editor-fold>
 
// <editor-fold defaultstate="collapsed" desc="valid">
 
  public boolean valid() {
    return ((getLoginNevPanel().getText() != null) && (getPasswordPanel().getText() != null));
  }
 
// </editor-fold>
 
// <editor-fold defaultstate="collapsed" desc="tkod">
 
  // TODO: befejezni
  public Integer getTkod() {
    return null;
  }
 
  public void setTkod(Integer mire) {
   
  }
 
// </editor-fold>
   
}
TOP

Related Classes of swing.login.LoginForm

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.