Package JabberClient

Source Code of JabberClient.LoginWindow

package JabberClient;

import java.awt.Color;
import java.io.FileOutputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.ObjectInputStream;
import java.io.Serializable;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.*;
import org.jivesoftware.smack.ConnectionConfiguration;
import org.jivesoftware.smack.SASLAuthentication;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;


public class LoginWindow extends javax.swing.JFrame implements Serializable {

    final static long serialVersionUID = 1;
    private XMPPConnection xmppconnection;
    private boolean blnLogin;
    private SnapshotLoginWindow snapshotloginwindow;
    private ComboBoxModel comboboxmodel = null;

    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new LoginWindow().setVisible(true);
            }
        });
    }

    public LoginWindow() {
        snapshotloginwindow = new SnapshotLoginWindow("","","","","",false,false,0);
        initComponents();
        createStatus();
        deserialize();
        this.getRootPane().setDefaultButton(jbtConnect);
       
    }

    public void createStatus() {

        Vector <ComboItem> vComboBox = new Vector <ComboItem> ();

        vComboBox.add(new ComboItem("available", "online", Color.GREEN));
        vComboBox.add(new ComboItem("xa", "nicht verfügbar", Color.GRAY));
        vComboBox.add(new ComboItem("away", "abwesend", Color.ORANGE));
        vComboBox.add(new ComboItem("dnd", "beschäftigt", Color.RED));

        ComboBoxCellRenderer renderer = new ComboBoxCellRenderer();

        comboboxmodel = new DefaultComboBoxModel(vComboBox);

        jComboBoxStatus.setModel(comboboxmodel);
        jComboBoxStatus.setRenderer(renderer);
        jComboBoxStatus.setSelectedIndex(0);
        jComboBoxStatus.setForeground(((ComboItem)jComboBoxStatus.getSelectedItem()).getColor());
    }

    public ComboBoxModel getComboBoxItems () {
        return comboboxmodel;
    }

    public int getComboBoxSelectedItem () {
        return jComboBoxStatus.getSelectedIndex();
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        txtUsername = new javax.swing.JTextField();
        jPanel2 = new javax.swing.JPanel();
        jpwdPassword = new javax.swing.JPasswordField();
        jbtConnect = new javax.swing.JButton();
        jComboBoxStatus = new javax.swing.JComboBox();
        jCheckBoxBenutzername = new javax.swing.JCheckBox();
        jCheckBoxPasswort = new javax.swing.JCheckBox();
        jPanel3 = new javax.swing.JPanel();
        txtServerIP = new javax.swing.JTextField();
        txtPort = new javax.swing.JTextField();
        label1 = new java.awt.Label();
        label2 = new java.awt.Label();
        label4 = new java.awt.Label();
        comboRessource = new javax.swing.JComboBox();
        label3 = new java.awt.Label();
        lblStateConn = new java.awt.Label();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenuItem3 = new javax.swing.JMenuItem();
        jMenuItem1 = new javax.swing.JMenuItem();
        jMenuItem4 = new javax.swing.JMenuItem();
        jMenu3 = new javax.swing.JMenu();
        jMenuItem2 = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setResizable(false);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosed(java.awt.event.WindowEvent evt) {
                formWindowClosed(evt);
            }
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
        });

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Benutzername"));

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(txtUsername, javax.swing.GroupLayout.PREFERRED_SIZE, 209, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(txtUsername, javax.swing.GroupLayout.DEFAULT_SIZE, 20, Short.MAX_VALUE)
                .addContainerGap())
        );

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Passwort"));
        jPanel2.setPreferredSize(new java.awt.Dimension(256, 54));

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jpwdPassword, javax.swing.GroupLayout.PREFERRED_SIZE, 209, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addComponent(jpwdPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jbtConnect.setText("Anmelden");
        jbtConnect.setName("jbtConnect"); // NOI18N
        jbtConnect.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtConnectActionPerformed(evt);
            }
        });

        jComboBoxStatus.setForeground(new java.awt.Color(204, 204, 0));
        jComboBoxStatus.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBoxStatusActionPerformed(evt);
            }
        });

        jCheckBoxBenutzername.setText("Benutzername merken");

        jCheckBoxPasswort.setText("Kennwort speichern");

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Servereinstellungen"));

        txtPort.setText("5222");

        label1.setText("IP:");

        label2.setText("Port:");

        label4.setText("Ressource:");

        comboRessource.setEditable(true);
        comboRessource.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Smack", "Home", "Work" }));

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(label1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(label2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(40, 40, 40))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(label4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(1, 1, 1)))
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(comboRessource, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(txtPort)
                    .addComponent(txtServerIP, javax.swing.GroupLayout.DEFAULT_SIZE, 140, Short.MAX_VALUE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(label1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtServerIP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(label2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(label4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(comboRessource, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        label3.setText("Status:");

        lblStateConn.setFont(new java.awt.Font("Dialog", 1, 12));
        lblStateConn.setForeground(new java.awt.Color(255, 0, 0));

        jMenu1.setText("Hauptmenü");

        jMenuItem3.setText("neues Konto");
        jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem3ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem3);

        jMenuItem1.setText("Optionen");
        jMenu1.add(jMenuItem1);

        jMenuItem4.setText("Beenden");
        jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem4ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem4);

        jMenuBar1.add(jMenu1);

        jMenu3.setText("Hilfe");

        jMenuItem2.setText("Messengerhilfe");
        jMenu3.add(jMenuItem2);

        jMenuBar1.add(jMenu3);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jCheckBoxPasswort)
                    .addComponent(jCheckBoxBenutzername)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                            .addComponent(label3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(2, 2, 2)
                            .addComponent(lblStateConn, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                            .addComponent(jComboBoxStatus, javax.swing.GroupLayout.PREFERRED_SIZE, 123, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(18, 18, 18)
                            .addComponent(jbtConnect, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(jPanel3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 241, Short.MAX_VALUE)
                        .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jCheckBoxBenutzername)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jCheckBoxPasswort)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jbtConnect)
                    .addComponent(jComboBoxStatus, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(label3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblStateConn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(40, 40, 40))
        );

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-277)/2, (screenSize.height-438)/2, 277, 438);
    }// </editor-fold>//GEN-END:initComponents

    private void jComboBoxStatusActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxStatusActionPerformed
        jComboBoxStatus.setForeground(((ComboItem)jComboBoxStatus.getSelectedItem()).getColor());
    }//GEN-LAST:event_jComboBoxStatusActionPerformed

    private void jbtConnectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtConnectActionPerformed
        XMPPConnection.DEBUG_ENABLED = false;

        if (jbtConnect.getText().equals("Anmelden")){
            createConnection();
            if (blnLogin){
                login();
                serialize();}
            }
        else{
            disconnect();
        }
    }//GEN-LAST:event_jbtConnectActionPerformed

// status nur den index übergeben, funktioniert NICHT
    private void setSnapshotObject(){
        if(jCheckBoxBenutzername.isSelected()){
            snapshotloginwindow.setstrUser(txtUsername.getText());}
        else{
            snapshotloginwindow.setstrUser("");
        }
       if(jCheckBoxPasswort.isSelected()){
            snapshotloginwindow.setstrPassword(jpwdPassword.getText());}
        else{
            snapshotloginwindow.setstrPassword("");
        }
        snapshotloginwindow.setstrIP(txtServerIP.getText());
        snapshotloginwindow.setstrPort(txtPort.getText());
        snapshotloginwindow.setstrRessource(comboRessource.getSelectedItem().toString());
        snapshotloginwindow.setblSaveUsername(jCheckBoxBenutzername.isSelected());
        snapshotloginwindow.setblSavePassword(jCheckBoxPasswort.isSelected());
        System.out.println("Wert Status: " + jComboBoxStatus.getSelectedIndex());
        snapshotloginwindow.setintStatus(jComboBoxStatus.getSelectedIndex());
    }

    private void getSnapshotObject(){
        txtUsername.setText(snapshotloginwindow.getstrUser());
        jpwdPassword.setText(snapshotloginwindow.getstrPassword());
        txtServerIP.setText(snapshotloginwindow.getstrIP());
        txtPort.setText(snapshotloginwindow.getstrPort());
        comboRessource.setSelectedItem(snapshotloginwindow.getstrRessource());
        jCheckBoxBenutzername.setSelected(snapshotloginwindow.getblSaveUsername());
        jCheckBoxPasswort.setSelected(snapshotloginwindow.getblSavePassword());
        jComboBoxStatus.setSelectedIndex(snapshotloginwindow.getintStatus());
    }


    private void formWindowClosed(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosed
      
    }//GEN-LAST:event_formWindowClosed

    private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
        serialize();
    }//GEN-LAST:event_formWindowClosing

    private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem4ActionPerformed
        serialize();
        System.exit(0);
    }//GEN-LAST:event_jMenuItem4ActionPerformed

    private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed
        new UseraccountWindow().setVisible(true);
        this.dispose();
    }//GEN-LAST:event_jMenuItem3ActionPerformed


    private void serialize(){
        try {
            setSnapshotObject();
            FileOutputStream file = new FileOutputStream( "xmppMessenger.ser" );
            ObjectOutputStream objOut = new ObjectOutputStream( file );
            objOut.writeObject  ( snapshotloginwindow );
            objOut.close();
        } catch (IOException ex) {
            Logger.getLogger(LoginWindow.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    private void deserialize(){
        try {
            FileInputStream file = new FileInputStream( "xmppMessenger.ser" );
            ObjectInputStream objIn = new ObjectInputStream( file );
            snapshotloginwindow = (SnapshotLoginWindow) objIn.readObject();
            objIn.close();
            getSnapshotObject();

        } catch (IOException ex) {
            System.out.println("IOException beim deserialisieren......");
            ex.printStackTrace();
        } catch (ClassNotFoundException ex){
            System.out.println("ClassNotFoundException beim deserialisieren......");
            ex.printStackTrace();
        }
    }


    private void login() {
            try {
            //einloggen
            xmppconnection.login(txtUsername.getText().toLowerCase(), jpwdPassword.getText(), comboRessource.getSelectedItem().toString());
            lblStateConn.setForeground(Color.green);
            lblStateConn.setText("Verbunden!");
            jbtConnect.setText("Abmelden");

            MainWindow mainWindow = new MainWindow(xmppconnection, this);
            mainWindow.setVisible(true);
            this.setVisible(false);
            }
            catch (XMPPException e) {
                lblStateConn.setForeground(Color.red);
                lblStateConn.setText("Benutzername oder Passwort falsch.");
            }

}

    private void createConnection(){
        if (checkFields().equals("")){
            try {
            if (!txtServerIP.getText().equals("")){
                ConnectionConfiguration conConfig = new ConnectionConfiguration(txtServerIP.getText(), Integer.parseInt(txtPort.getText()));
                conConfig.setSASLAuthenticationEnabled(true);
                SASLAuthentication.supportSASLMechanism("PLAIN", 0);
                conConfig.setReconnectionAllowed(true);

                xmppconnection = new XMPPConnection(conConfig);
                xmppconnection.connect();
                blnLogin = true;
            }
            else{
                blnLogin = false;
            }
            }
            catch (XMPPException e){
                System.out.println(e.getXMPPError());
                lblStateConn.setText("Server-IP und Port überprüfen.");
            }
        }
        else{
            lblStateConn.setText(checkFields());
            blnLogin = false;
        }
    }

    private String checkFields(){

       String strERR = "";
       int iCount = 0;

       if (txtUsername.getText().isEmpty()){
           if (iCount == 0){
               strERR = "Username nicht angegeben!";}
           else{
               strERR = "Mehrere Felder leer!";}
           iCount++;
       }
       if (jpwdPassword.getText().isEmpty()){
           if (iCount == 0){
               strERR = "Passwort nicht angegeben!";}
           else{
               strERR = "Mehrere Felder leer!";}
           iCount++;
       }
       if (txtServerIP.getText().isEmpty()){
           if (iCount == 0){
               strERR = "IP nicht angegeben!";}
           else{
               strERR = "Mehrere Felder leer!";}
           iCount++;
       }
       if (txtPort.getText().isEmpty()){
           if (iCount == 0){
               strERR = "Port nicht angegeben!";}
           else{
               strERR = "Mehrere Felder leer!";}
           iCount++;
       }
       return strERR;
    }

    public void disconnect() {
        xmppconnection.disconnect();
        lblStateConn.setForeground(Color.red);
        lblStateConn.setText("Nicht verbunden!");
        jbtConnect.setText("Anmelden");
    }

   
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox comboRessource;
    private javax.swing.JCheckBox jCheckBoxBenutzername;
    private javax.swing.JCheckBox jCheckBoxPasswort;
    private javax.swing.JComboBox jComboBoxStatus;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JMenuItem jMenuItem3;
    private javax.swing.JMenuItem jMenuItem4;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JButton jbtConnect;
    private javax.swing.JPasswordField jpwdPassword;
    private java.awt.Label label1;
    private java.awt.Label label2;
    private java.awt.Label label3;
    private java.awt.Label label4;
    private java.awt.Label lblStateConn;
    private javax.swing.JTextField txtPort;
    private javax.swing.JTextField txtServerIP;
    private javax.swing.JTextField txtUsername;
    // End of variables declaration//GEN-END:variables

}
TOP

Related Classes of JabberClient.LoginWindow

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.