Page 1 of 3 123 LastLast
Results 1 to 20 of 41
  1. #1
    raj.mscking@gmail.com's Avatar
    raj.mscking@gmail.com is offline Senior Member
    Join Date
    Jan 2012
    Location
    TamilNadu
    Posts
    288
    Rep Power
    3

    Default USerName, Password From Cliet

    Good to meet you all!

    In my program, The ServerSocket want's to receive the UserName, Password From Client when Client Login,

    Any one can help me,

    i try to use ServerSocket / Socket

    i don't kow how to set the stream to ServerSocket

    else
    can you please show me the model coding for "Get input from user on Socket"

    Thank you..,

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,562
    Rep Power
    25

    Default Re: USerName, Password From Cliet

    Get input from user
    Are you using a GUI or the console to get user input?
    With the console you can use the Scanner class to get input from a user. Or you could use a JOptionPane that would put up a window for the input.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    raj.mscking@gmail.com's Avatar
    raj.mscking@gmail.com is offline Senior Member
    Join Date
    Jan 2012
    Location
    TamilNadu
    Posts
    288
    Rep Power
    3

    Default Re: USerName, Password From Cliet

    I Thanking you for your response sir,
    i am using JTextBox and JPassWord field in swing sir..,

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,562
    Rep Power
    25

    Default Re: USerName, Password From Cliet

    Then what does your code do after it gets the user's input?
    If you don't understand my response, don't ignore it, ask a question.

  5. #5
    raj.mscking@gmail.com's Avatar
    raj.mscking@gmail.com is offline Senior Member
    Join Date
    Jan 2012
    Location
    TamilNadu
    Posts
    288
    Rep Power
    3

    Question problem with Database to access Server/ServerSocket

    Good To Meet you All!

    Sir In my server

    This is the JButton action for start server

    Java Code:
    private void strsrvActionPerformed(java.awt.event.ActionEvent evt) {                                         
        getClint();
    }
    This is action Performed sir..,

    Java Code:
    public void getClint()
    {
        
             
                    try
                    {
                ServerSocket ss=new ServerSocket(1030);
                
                     
                            try
                            {
                                JOptionPane.showMessageDialog(null,"Server is runing");
                            while(true)
                       {
                           Socket s=ss.accept();
                           Service a=new Service(s);
                           a.start();
                       }
                            }
                            catch(Exception e)
                            {
                                  System.out.println(e);
                    }
                }
    
            catch(IOException ex)
            {
                Logger.getLogger(MainF.class.getName()).log(Level.SEVERE, null,ex);
            }
    }
    This Is the Inner class code for to access clients

    Java Code:
    public class Service extends Thread 
    {
            public Socket s;
            public Service(Socket t) 
                    
            {
                 s=t;
            }
            public void run()
            {
                try
        {
             BufferedReader input = new BufferedReader(new InputStreamReader(s.getInputStream()));
                    PrintWriter output = new PrintWriter(new OutputStreamWriter(s.getOutputStream()));
                    String userName = input.readLine();
                    String password = input.readLine();
                    String getd=input.readLine();
                    try {
            Class.forName("com.mysql.jdbc.Driver");
            Connection conn = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/payslip", "root", "root");
            PreparedStatement ps = conn.prepareStatement("select * from employeenew where un='"+userName+"' and pw='"+password+"'");
             ps.execute();
           while(true)
            {
                PreparedStatement ps1 = conn.prepareStatement("insert into attents (un='"+userName+"',pw='"+password+"',intim='"+getd+"')");
                output.println("You Have LogIn" + userName);
                ps1.executeUpdate();
                 conn.close();
              }
                
        } catch (Exception e) {
            JOptionPane.showMessageDialog(rootPane,"LoginFailed");
        }
                    output.close();
                    input.close();
                    s.close();
                    }
                    catch(Exception e)
                    {
                        System.out.println(e);
                    }
                }
                }

    The client code is

    Java Code:
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    
    /*
     * Client.java
     *
     * Created on Apr 28, 2012, 10:58:31 AM
     */
    
    import java.io.*;
    import java.net.*;
    import java.util.Calendar;
    import java.util.Date;
    import javax.swing.JOptionPane;
    /**
     *
     * @author e-soft
     */
    public class Client extends javax.swing.JFrame {
    Socket s;
        /** Creates new form Client */
        public Client() {
            initComponents();
        }
            /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
         */
        @SuppressWarnings("unchecked")
        // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
        private void initComponents() {
    
            un = new javax.swing.JTextField();
            pw = new javax.swing.JTextField();
            lin = new javax.swing.JButton();
            lo = new javax.swing.JButton();
    
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    
            lin.setText("LogIn");
            lin.addMouseListener(new java.awt.event.MouseAdapter() {
                public void mousePressed(java.awt.event.MouseEvent evt) {
                    linMousePressed(evt);
                }
            });
            lin.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    linActionPerformed(evt);
                }
            });
    
            lo.setText("LogOut");
            lo.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    loActionPerformed(evt);
                }
            });
    
            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)
                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(pw, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(un, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGap(22, 22, 22))
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(lin)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 94, Short.MAX_VALUE)
                            .addComponent(lo)
                            .addGap(79, 79, 79))))
            );
            layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(37, 37, 37)
                    .addComponent(un, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(18, 18, 18)
                    .addComponent(pw, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(lin)
                        .addComponent(lo))
                    .addContainerGap(24, Short.MAX_VALUE))
            );
    
            pack();
        }// </editor-fold>                        
    
    private void linActionPerformed(java.awt.event.ActionEvent evt) {                                    
    // TODO add your handling code here:
             try
            {
          Socket s=new Socket("192.168.1.8",1030);
          PrintWriter output = new PrintWriter(new OutputStreamWriter(s.getOutputStream()));
          String userName =un.getText();
          output.println(userName);
          String password =pw.getText();
          output.println(password);
          Date dt=Calendar.getInstance().getTime();
          Date timzn=(dt);
          output.println(timzn);
          output.flush();
          BufferedReader input = new BufferedReader(new InputStreamReader(s.getInputStream()));
          String response = input.readLine();
          JOptionPane.showMessageDialog(rootPane, response);
          output.close();
          input.close();
          s.close();
          lo.setEnabled(true);
          lin.setEnabled(false);
           }
            catch (Exception e)
            {
                JOptionPane.showMessageDialog(rootPane, "Server Is Not In Conection");
                
           }
         
    }                                   
    
    private void loActionPerformed(java.awt.event.ActionEvent evt) {                                   
    // TODO add your handling code here:
        lin.setEnabled(true);
        lo.setEnabled(false);
    }                                  
    
    private void linMousePressed(java.awt.event.MouseEvent evt) {                                 
    // TODO add your handling code here:
         
    }                                
    
        /**
         * @param args the command line arguments
         */
        public static void main(String args[]) {
            
                   /* Set the Nimbus look and feel */
            //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
            /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
             * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
             */
            try {
                for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                    if ("Nimbus".equals(info.getName())) {
                        javax.swing.UIManager.setLookAndFeel(info.getClassName());
                        break;
                    }
                }
            } catch (ClassNotFoundException ex) {
                java.util.logging.Logger.getLogger(Client.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
            } catch (InstantiationException ex) {
                java.util.logging.Logger.getLogger(Client.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
            } catch (IllegalAccessException ex) {
                java.util.logging.Logger.getLogger(Client.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
            } catch (javax.swing.UnsupportedLookAndFeelException ex) {
                java.util.logging.Logger.getLogger(Client.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
            }
            //</editor-fold>
    
            /* Create and display the form */
            java.awt.EventQueue.invokeLater(new Runnable() {
    
                public void run() {
                    new Client().setVisible(true);
                }
            });
        }
        // Variables declaration - do not modify                     
        private javax.swing.JButton lin;
        private javax.swing.JButton lo;
        private javax.swing.JTextField pw;
        private javax.swing.JTextField un;
        // End of variables declaration                   
    }


    My problem is
    the server can use the username and password as static declaration only

    But

    if i connect to database it showing error while before access the database,
    (even it not access the database try Block)
    and the error message also unable to read, it showing transparent-able or black screen sir..,

    (I Don't know how to properly use the database with server)

    Anyone can help me please..,
    Thank you..,

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,562
    Rep Power
    25

    Default Re: USerName, Password From Cliet

    the error message also unable to read
    Please explain.
    You need to add a call to the printStacktTrace() method in the catch blocks so that the full text of the error message is shown.


    To copy the contents of the command prompt window:
    Click on Icon in upper left corner
    Select Edit
    Select 'Select All' - The selection will show
    Click in upper left again
    Select Edit and click 'Copy'

    Paste here.
    If you don't understand my response, don't ignore it, ask a question.

  7. #7
    raj.mscking@gmail.com's Avatar
    raj.mscking@gmail.com is offline Senior Member
    Join Date
    Jan 2012
    Location
    TamilNadu
    Posts
    288
    Rep Power
    3

    Default Re: USerName, Password From Cliet

    sorry sir!

    If i add e.printStackTrace() also it doesn't show nothing, even in my IDE command prompt also

    Java Code:
    catch (Exception e) {
                    e.printStackTrace();
        }
    sorry to show you the error as images sir..,
    USerName, Password From Cliet-pin.jpgUSerName, Password From Cliet-two.jpgUSerName, Password From Cliet-tri.jpg

  8. #8
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,562
    Rep Power
    25

    Default Re: USerName, Password From Cliet

    it showing error
    Please explain what error is showing?
    Did you add the call to printStackTrace to all the catch blocks?
    If you don't understand my response, don't ignore it, ask a question.

  9. #9
    raj.mscking@gmail.com's Avatar
    raj.mscking@gmail.com is offline Senior Member
    Join Date
    Jan 2012
    Location
    TamilNadu
    Posts
    288
    Rep Power
    3

    Default Re: USerName, Password From Cliet

    Thank you sir!
    i made a small changes in my code sir,
    it allow the user to access the server.
    the problem is, i fail to close the proper braces sir,
    i very thank you sir..,

  10. #10
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,562
    Rep Power
    25

    Default Re: USerName, Password From Cliet

    Was it the stupid IDE that did not give you a compiler error message?
    If you don't understand my response, don't ignore it, ask a question.

  11. #11
    raj.mscking@gmail.com's Avatar
    raj.mscking@gmail.com is offline Senior Member
    Join Date
    Jan 2012
    Location
    TamilNadu
    Posts
    288
    Rep Power
    3

    Default Re: USerName, Password From Cliet

    sir that is not a IDE problem sir,
    I made that Stupid thing,
    By mistakenly i mark that braces as lines of //,
    when it ask me "run with error " i select "ok" sir ,
    it is my mistake only.
    sorry for that sir..,

  12. #12
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,562
    Rep Power
    25

    Default Re: USerName, Password From Cliet

    If you don't understand my response, don't ignore it, ask a question.

  13. #13
    raj.mscking@gmail.com's Avatar
    raj.mscking@gmail.com is offline Senior Member
    Join Date
    Jan 2012
    Location
    TamilNadu
    Posts
    288
    Rep Power
    3

    Question Re: USerName, Password From Cliet

    Hi Nice to meet you!

    In my part of the application i wants to start the server for receive the user log in info ,
    (username, password & log in time)

    All parts in my application is working well but if i start the server my total application is Become Black and Unable to do any action in that,

    If i run individually it is working well sir..,

    For the past 8hrs i try to find solution but it is making problems only..,

    The server side only making problem

    code for server for multiple client

    Java Code:
     try
            {
             ServerSocket ss=new ServerSocket(1099);
                    try
                    {
                        JOptionPane.showMessageDialog(null,"Server is runing");
                        System.out.println("server started");
               while(true)
               {
                   Socket s=ss.accept();
                   Service a=new Service(s);
                   a.start();
               }
                    }
                    catch(Exception e)
                    {
                        System.out.println(e);
                    }
            }
            catch(IOException ex)
            {
                Logger.getLogger(Server.class.getName()).log(Level.SEVERE, null,ex);
            }
    The service Class for handler

    Java Code:
    package test;
    
    
    import tcp.*;
    import java.io.*;
    import java.net.*;
    import java.sql.*;
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    
    /**
     *
     * @author
     */
    public class Service extends Thread 
    {
            private Socket s=null;
        private PrintStream out= null;
        private DataInputStream in=null;
        BufferedReader input=null;
        public Service(Socket t)throws Exception             
            {
                 s=t;
                 out=new PrintStream(s.getOutputStream());
                 in=new DataInputStream(s.getInputStream());
            }
            public void run()
            {
                try
        {
                    BufferedReader input = new BufferedReader(new InputStreamReader(s.getInputStream()));
                    PrintWriter output = new PrintWriter(s.getOutputStream(),true);
                    while(true)
                    {
                    String userName = input.readLine();
                    String password = input.readLine();
                    String getd=input.readLine();
                    try {
            Class.forName("com.mysql.jdbc.Driver");
            Connection conn = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/payslip", "root", "root");
            PreparedStatement ps = conn.prepareStatement("select * from employeenew where un='"+userName+"' and pw='"+password+"'");
             ps.execute();
           while(true)
            {
                PreparedStatement ps1 = conn.prepareStatement("insert into attents (un='"+userName+"',pw='"+password+"',intim='"+getd+"')");
                output.println("You Have LogIn" + userName);
                ps1.executeUpdate();
                 conn.close();
              }
                
        } catch (Exception e) {
                    e.printStackTrace();
        }
                      }
        }
                    catch(Exception e)
                    {
                        e.printStackTrace();
                        
                        
                        
                    }
            }
    }
    I am waiting for your response please..,

  14. #14
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,562
    Rep Power
    25

    Default Re: USerName, Password From Cliet

    but if i start the server my total application is Become Black
    Please explain how you are executing the programs in your application. How is each one started. What does each one do when it starts.
    What does "become black" mean?
    If you don't understand my response, don't ignore it, ask a question.

  15. #15
    raj.mscking@gmail.com's Avatar
    raj.mscking@gmail.com is offline Senior Member
    Join Date
    Jan 2012
    Location
    TamilNadu
    Posts
    288
    Rep Power
    3

    Default Re: USerName, Password From Cliet

    Thank you sir!
    i will explain to you,

    In my pay slip program i have Modules of (Workers info, Pay slip,Leave info and Attendance)

    In that attendance panel i have option to start & stop server (if any worker at morning logged in with client application (username, password & System time) )
    (Sorry for attach as picture sir)
    USerName, Password From Cliet-one.jpg
    it will be sent to my Payslip application
    USerName, Password From Cliet-two.jpg
    the application is working well. (Before start the server)
    USerName, Password From Cliet-three.jpg
    But!

    if i start the server it will become
    USerName, Password From Cliet-four.jpg
    like this sir..,

    Thank you sir..,

  16. #16
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,562
    Rep Power
    25

    Default Re: USerName, Password From Cliet

    if i start the server it will become
    What is the "it" that becomes?
    Try executing the code in a command prompt and not in an IDE. So the IDE can NOT affect what the code is doing.
    Add some println statements to the servers code so you can see where it has executed and where the execution has stopped waiting for input or whatever.
    If you don't understand my response, don't ignore it, ask a question.

  17. #17
    raj.mscking@gmail.com's Avatar
    raj.mscking@gmail.com is offline Senior Member
    Join Date
    Jan 2012
    Location
    TamilNadu
    Posts
    288
    Rep Power
    3

    Default Re: USerName, Password From Cliet

    Thank you sir!
    i fallow your guide now..,

  18. #18
    raj.mscking@gmail.com's Avatar
    raj.mscking@gmail.com is offline Senior Member
    Join Date
    Jan 2012
    Location
    TamilNadu
    Posts
    288
    Rep Power
    3

    Default Re: USerName, Password From Cliet

    "it" meant the Payslip application sir..,

  19. #19
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,562
    Rep Power
    25

    Default Re: USerName, Password From Cliet

    are there any error messages on the console?

    Can you post a small simple program for the server and client that will compile. execute and show the problem? I don't see complete code here for a server.
    Last edited by Norm; 05-01-2012 at 01:24 PM. Reason: Request code for server
    If you don't understand my response, don't ignore it, ask a question.

  20. #20
    raj.mscking@gmail.com's Avatar
    raj.mscking@gmail.com is offline Senior Member
    Join Date
    Jan 2012
    Location
    TamilNadu
    Posts
    288
    Rep Power
    3

    Default Re: USerName, Password From Cliet

    ok sir!

    Java Code:
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    
    /*
     * serverFm.java
     *
     * Created on May 1, 2012, 10:25:17 AM
     */
    /**
     *
     * @author
     */
    import java.net.*;
    import java.io.*;
    import java.sql.*;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import javax.swing.JOptionPane;
    public class serverFm extends javax.swing.JFrame {
        ServerSocket server = null;
        Socket client = null;
        BufferedReader in = null;
        PrintWriter out = null;
        String UName;
        String Passw;
        String getd;
    
        /** Creates new form serverFm */
        public serverFm() {
            initComponents();
            UName = "";
            Passw="";
            getd="";
        }
        public void service()
        {
            try
            {
                server = new ServerSocket(1099);
                client = server.accept();
            }
            catch(Exception e)
            {
                JOptionPane.showMessageDialog(rootPane,"Accept failed :");
                        }
            try
            {
                in = new BufferedReader(new InputStreamReader(client.getInputStream()));
                out = new PrintWriter(client.getOutputStream(), true);
            } catch (IOException e)
            {
                JOptionPane.showMessageDialog(rootPane,"Read failed");
                System.exit(-1);
            }
            if(true)
            {
                try
                {
                    UName = in.readLine();
                    Passw=in.readLine();
                    getd=in.readLine();
                    
                    //Send data back to client
                     
                    //out.println(Passw);
                  try {
            Class.forName("com.mysql.jdbc.Driver");
            Connection conn = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/payslip", "root", "root");
            PreparedStatement ps = conn.prepareStatement("select * from employeenew where un='"+UName+"' and pw='"+Passw+"'");
            ps.execute();
                   
           if(true)
            {
                try
                {
                PreparedStatement ps1 = conn.prepareStatement("INSERT INTO payslip.attents (un, pw, intim) VALUES(?,?,?)");
                ps1.setString(1, UName);
                ps1.setString(2, Passw);
                ps1.setString(3, getd);
                JOptionPane.showMessageDialog(null,"You Have LogIn with " + UName);
                ps1.executeUpdate();
                JOptionPane.showMessageDialog(rootPane,"Login successfully");
                            }
           catch(Exception e)
           {
               JOptionPane.showMessageDialog(rootPane, "Check Your UserName & PassWord Please..,");
           }
                
            }
                
        } catch (Exception e) {
                    e.printStackTrace();
        }
                   out.println(UName);
                }
                catch (IOException ex) {
                    Logger.getLogger(serverFm.class.getName()).log(Level.SEVERE, null, ex);
                }        } 
        }
    
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
         */
        @SuppressWarnings("unchecked")
        // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
        private void initComponents() {
    
            hai = new javax.swing.JTextField();
            pwws = new javax.swing.JPasswordField();
            jButton1 = new javax.swing.JButton();
            dttte = new javax.swing.JLabel();
    
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            addWindowListener(new java.awt.event.WindowAdapter() {
                public void windowClosed(java.awt.event.WindowEvent evt) {
                    formWindowClosed(evt);
                }
            });
    
            jButton1.setText("Get");
            jButton1.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton1ActionPerformed(evt);
                }
            });
    
            javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
            getContentPane().setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(147, 147, 147)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(pwws, javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(hai, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 157, Short.MAX_VALUE))
                    .addContainerGap(96, Short.MAX_VALUE))
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                    .addContainerGap(168, Short.MAX_VALUE)
                    .addComponent(jButton1)
                    .addGap(183, 183, 183))
                .addGroup(layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(dttte, javax.swing.GroupLayout.PREFERRED_SIZE, 152, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(238, Short.MAX_VALUE))
            );
            layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addComponent(dttte, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(hai, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(18, 18, 18)
                    .addComponent(pwws, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(26, 26, 26)
                    .addComponent(jButton1)
                    .addContainerGap(19, Short.MAX_VALUE))
            );
    
            pack();
        }// </editor-fold>                        
    
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
    // TODO add your handling code here:
    }                                        
    
    private void formWindowClosed(java.awt.event.WindowEvent evt) {                                  
    // TODO add your handling code here:
        try
            {
                in.close();
                out.close();
                server.close();
            }
            catch (IOException e)
            {
                JOptionPane.showMessageDialog(rootPane,"Could not close.");
                System.exit(-1);
            }
     
    }                                 
    
        /**
         * @param args the command line arguments
         */
        public static void main(String args[]) {
            /* Set the Nimbus look and feel */
            //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
            /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
             * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
             */
            try {
                for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                    if ("Nimbus".equals(info.getName())) {
                        javax.swing.UIManager.setLookAndFeel(info.getClassName());
                        break;
                    }
                }
            } catch (ClassNotFoundException ex) {
                java.util.logging.Logger.getLogger(serverFm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
            } catch (InstantiationException ex) {
                java.util.logging.Logger.getLogger(serverFm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
            } catch (IllegalAccessException ex) {
                java.util.logging.Logger.getLogger(serverFm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
            } catch (javax.swing.UnsupportedLookAndFeelException ex) {
                java.util.logging.Logger.getLogger(serverFm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
            }
            //</editor-fold>
    
            /* Create and display the form */
            java.awt.EventQueue.invokeLater(new Runnable() {
    
                public void run() {
                    new serverFm().setVisible(true);
                }
            });
        }
        // Variables declaration - do not modify                     
        private javax.swing.JLabel dttte;
        private javax.swing.JTextField hai;
        private javax.swing.JButton jButton1;
        private javax.swing.JPasswordField pwws;
        // End of variables declaration                   
    }



    Java Code:
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    
    
    /**
     *
     * @author
     */
    public class ServerMain
    {
        public static void main(String[] args)
        {
            serverFm s = new serverFm();
            s.setVisible(true);
            s.service();
            }
    }

Page 1 of 3 123 LastLast

Similar Threads

  1. Username And Password
    By razmyasdfg in forum JDBC
    Replies: 9
    Last Post: 05-18-2011, 02:59 PM
  2. New to GUI. Logging in with Password and username
    By slitka in forum New To Java
    Replies: 3
    Last Post: 04-11-2011, 11:39 PM
  3. Encrypt Password and Username
    By hardcorebadger in forum New To Java
    Replies: 5
    Last Post: 01-26-2011, 03:47 PM
  4. how to link url with username and password
    By gb.rashu in forum JavaServer Pages (JSP) and JSTL
    Replies: 13
    Last Post: 08-12-2010, 03:12 PM
  5. JTextFields with username & password.
    By Eric in forum AWT / Swing
    Replies: 2
    Last Post: 07-01-2007, 11:41 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •