Advertisement
Guest User

Bijoy

a guest
Jan 14th, 2012
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 9.27 KB | None | 0 0
  1. /*
  2.  * To change this template, choose Tools | Templates
  3.  * and open the template in the editor.
  4.  */
  5.  
  6. /*
  7.  * XMPPClient.java
  8.  *
  9.  * Created on Jan 7, 2012, 12:21:01 AM
  10.  */
  11. package xmpp;
  12.  
  13. import java.awt.Image;
  14. import java.io.File;
  15. import java.io.IOException;
  16. import java.util.logging.Level;
  17. import java.util.logging.Logger;
  18. import javax.swing.DefaultCellEditor;
  19. import javax.swing.JButton;
  20. import javax.swing.JCheckBox;
  21. import javax.swing.JComboBox;
  22. import javax.swing.JRadioButton;
  23. import javax.swing.table.DefaultTableModel;
  24. import javax.swing.table.TableCellEditor;
  25. import javax.swing.table.TableColumn;
  26. import javax.swing.text.TableView.TableRow;
  27.  
  28. /**
  29.  *
  30.  * @author BIJOY
  31.  */
  32. public class XMPPClient extends javax.swing.JFrame {
  33.  
  34.     /** Creates new form XMPPClient */
  35.     public static Users usr;
  36.     public XMPPClient() throws IOException {
  37.         initComponents();
  38.         usr=new Users();
  39.         jXImageView1.setImage(new File("jabber.png"));
  40.         jXImageView1.setOpaque(false);
  41.        
  42.        
  43.        
  44.      
  45.  
  46.     }
  47.  
  48.     /** This method is called from within the constructor to
  49.      * initialize the form.
  50.      * WARNING: Do NOT modify this code. The content of this method is
  51.      * always regenerated by the Form Editor.
  52.      */
  53.     @SuppressWarnings("unchecked")
  54.     // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  55.     private void initComponents() {
  56.  
  57.         jPanel1 = new javax.swing.JPanel();
  58.         jLabel1 = new javax.swing.JLabel();
  59.         jLabel2 = new javax.swing.JLabel();
  60.         jTextField1 = new javax.swing.JTextField();
  61.         jCheckBox1 = new javax.swing.JCheckBox();
  62.         jButton1 = new javax.swing.JButton();
  63.         jPasswordField1 = new javax.swing.JPasswordField();
  64.         jSeparator1 = new javax.swing.JSeparator();
  65.         jLabel3 = new javax.swing.JLabel();
  66.         jTextField2 = new javax.swing.JTextField();
  67.         jXImageView1 = new org.jdesktop.swingx.JXImageView();
  68.  
  69.         setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  70.         setMinimumSize(null);
  71.         setResizable(false);
  72.  
  73.         jPanel1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
  74.  
  75.         jLabel1.setText("Username:");
  76.         jPanel1.add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 110, 96, -1));
  77.  
  78.         jLabel2.setText("Domain");
  79.         jPanel1.add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 210, 96, -1));
  80.         jPanel1.add(jTextField1, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 130, 165, -1));
  81.  
  82.         jCheckBox1.setText("Remember password");
  83.         jCheckBox1.addActionListener(new java.awt.event.ActionListener() {
  84.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  85.                 jCheckBox1ActionPerformed(evt);
  86.             }
  87.         });
  88.         jPanel1.add(jCheckBox1, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 253, 170, 20));
  89.  
  90.         jButton1.setText("Sign In");
  91.         jButton1.addActionListener(new java.awt.event.ActionListener() {
  92.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  93.                 jButton1ActionPerformed(evt);
  94.             }
  95.         });
  96.         jPanel1.add(jButton1, new org.netbeans.lib.awtextra.AbsoluteConstraints(50, 280, 118, -1));
  97.         jPanel1.add(jPasswordField1, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 180, 165, -1));
  98.         jPanel1.add(jSeparator1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 100, 220, 18));
  99.  
  100.         jLabel3.setText("Password");
  101.         jPanel1.add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 160, 96, -1));
  102.         jPanel1.add(jTextField2, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 230, 165, -1));
  103.  
  104.         jXImageView1.setEditable(false);
  105.  
  106.         javax.swing.GroupLayout jXImageView1Layout = new javax.swing.GroupLayout(jXImageView1);
  107.         jXImageView1.setLayout(jXImageView1Layout);
  108.         jXImageView1Layout.setHorizontalGroup(
  109.             jXImageView1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  110.             .addGap(0, 200, Short.MAX_VALUE)
  111.         );
  112.         jXImageView1Layout.setVerticalGroup(
  113.             jXImageView1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  114.             .addGap(0, 80, Short.MAX_VALUE)
  115.         );
  116.  
  117.         jPanel1.add(jXImageView1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 10, 200, 80));
  118.  
  119.         javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  120.         getContentPane().setLayout(layout);
  121.         layout.setHorizontalGroup(
  122.             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  123.             .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
  124.                 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  125.                 .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 220, javax.swing.GroupLayout.PREFERRED_SIZE)
  126.                 .addContainerGap())
  127.         );
  128.         layout.setVerticalGroup(
  129.             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  130.             .addGroup(layout.createSequentialGroup()
  131.                 .addContainerGap()
  132.                 .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
  133.                 .addContainerGap())
  134.         );
  135.  
  136.         pack();
  137.     }// </editor-fold>//GEN-END:initComponents
  138.  
  139. private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
  140. // TODO add your handling code here:
  141.  
  142.    
  143.        XMPP xmMain= new XMPP(jTextField1.getText(),jPasswordField1.getText(),jTextField2.getText());
  144.        
  145.        Thread xmppmain=new Thread(xmMain);
  146.        xmppmain.start();
  147.  
  148.        for(;;)
  149.        {
  150.            if(XMLParser.auth==1)
  151.            {
  152.                jPanel1.hide();
  153.                getContentPane().add(usr);
  154.                usr.setBounds(0,0,256,411);
  155.                usr.setVisible(true);
  156.                usr.paintAll(getGraphics());
  157.  
  158.                break;
  159.            }
  160.            else if(XMLParser.auth==3)
  161.            {
  162.                XMLParser.auth=0;
  163.                xmppmain.stop();
  164.                break;
  165.            }
  166.            
  167.            try {
  168.                 Thread.sleep(1000);
  169.             } catch (InterruptedException ex) {
  170.                 Logger.getLogger(XMPPClient.class.getName()).log(Level.SEVERE, null, ex);
  171.             }
  172.        
  173.        }
  174.        
  175.        repaint();
  176. }//GEN-LAST:event_jButton1ActionPerformed
  177.  
  178. private void jCheckBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox1ActionPerformed
  179. // TODO add your handling code here:
  180. }//GEN-LAST:event_jCheckBox1ActionPerformed
  181.  
  182.     /**
  183.      * @param args the command line arguments
  184.      */
  185.     public static void main(String args[]) {
  186.         /* Set the Nimbus look and feel */
  187.         //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
  188.         /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
  189.          * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
  190.          */
  191.         try {
  192.             for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
  193.                 if ("Nimbus".equals(info.getName())) {
  194.                     javax.swing.UIManager.setLookAndFeel(info.getClassName());
  195.                     break;
  196.                 }
  197.             }
  198.         } catch (ClassNotFoundException ex) {
  199.             java.util.logging.Logger.getLogger(XMPPClient.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  200.         } catch (InstantiationException ex) {
  201.             java.util.logging.Logger.getLogger(XMPPClient.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  202.         } catch (IllegalAccessException ex) {
  203.             java.util.logging.Logger.getLogger(XMPPClient.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  204.         } catch (javax.swing.UnsupportedLookAndFeelException ex) {
  205.             java.util.logging.Logger.getLogger(XMPPClient.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  206.         }
  207.         //</editor-fold>
  208.  
  209.         /* Create and display the form */
  210.         java.awt.EventQueue.invokeLater(new Runnable() {
  211.  
  212.             public void run() {
  213.                 try {
  214.                     new XMPPClient().setVisible(true);
  215.                 } catch (IOException ex) {
  216.                     Logger.getLogger(XMPPClient.class.getName()).log(Level.SEVERE, null, ex);
  217.                 }
  218.             }
  219.         });
  220.     }
  221.     // Variables declaration - do not modify//GEN-BEGIN:variables
  222.  
  223.     private javax.swing.JButton jButton1;
  224.     private javax.swing.JCheckBox jCheckBox1;
  225.     private javax.swing.JLabel jLabel1;
  226.     private javax.swing.JLabel jLabel2;
  227.     private javax.swing.JLabel jLabel3;
  228.     private javax.swing.JPanel jPanel1;
  229.     private javax.swing.JPasswordField jPasswordField1;
  230.     private javax.swing.JSeparator jSeparator1;
  231.     private javax.swing.JTextField jTextField1;
  232.     private javax.swing.JTextField jTextField2;
  233.     private org.jdesktop.swingx.JXImageView jXImageView1;
  234.     // End of variables declaration//GEN-END:variables
  235. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement