Package gui

Source Code of gui.ConnectionPanel

/*
* Hamsam - Instant Messaging API
* Copyright (C) 2003 Raghu K
*
* 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 gui;

import javax.swing.JTextField;
import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JPasswordField;
import javax.swing.JButton;
import javax.swing.JComboBox;

import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import java.awt.Insets;

import gui.tools.PropertiesManager;
import gui.tools.Traces;
import gui.action.MakeConnection;
import gui.action.ConnectionInfos;

/**
* <p>Titre : Hamsam Project</p>
* <p>Description : Instant Messenger</p>
* <p>Copyright : Copyright (c) 2003</p>
* <p>Soci�t� : </p>
* @author Fr�d�ric DIB
* @version 0.1
*/

public class ConnectionPanel
    extends JPanel {
  private PropertiesManager propertiesMgr = null;
  private JTextField loginField = new JTextField(20);
  private JLabel loginLabel = null;
  private JPasswordField passwordField = new JPasswordField(20);
  private JLabel passwordLabel = null;
  private JButton connectButton = null;
  private JComboBox protocolCombo = new JComboBox();

  /**
   * Constructor.
   */
  public ConnectionPanel(PropertiesManager p) {
    this.propertiesMgr = p;
    this.initConnectionPanel();
    this.temp();
  }

  /**
   * Init the connection panel.
   */
  private void initConnectionPanel() {
    loginLabel = new JLabel(this.propertiesMgr.getValue("loginLabel"),
                            JLabel.RIGHT);
    passwordLabel = new JLabel(this.propertiesMgr.getValue("passwordLabel"),
                               JLabel.RIGHT);
    connectButton = new JButton(this.propertiesMgr.getValue("connectButton"));
    connectButton.addActionListener(new MakeConnection(this, this.propertiesMgr));

    //Init the list of protocol available
    //ConnectionInfos. = ProtocolManager.getAvailableProtocols();
    Traces.printTraces("List of availables protocols : ");
    for (int i=0; i<ConnectionInfos.protocols.length; i++) {
        Traces.printTraces(ConnectionInfos.protocols[i].getProtocolName());
        protocolCombo.addItem(ConnectionInfos.protocols[i].getProtocolName());
    }

    this.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();

    c.weightx = 1;
    c.insets = new Insets(5, 5, 5, 5);
    //c.anchor = c.NORTHWEST;

    //First line
    c.gridy = 1;
    this.add(loginLabel, c);
    this.add(loginField, c);

    //second line
    c.gridy = 2;
    this.add(passwordLabel, c);
    this.add(passwordField, c);

    //third line
    c.gridy = 3;
    c.insets = new Insets(25, 5, 5, 5);
    this.add(connectButton, c);
    this.add(protocolCombo, c);
  }

  private void temp() {

  }

  public String getLogin() {return loginField.getText();}
  public String getPassword() {return new String(passwordField.getPassword());}
  public int getSelectedProtocol() {return protocolCombo.getSelectedIndex();}
}
TOP

Related Classes of gui.ConnectionPanel

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.