Exemple #1
0
  private void SignInButtonActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_SignInButtonActionPerformed

    /* username i password spojit u jedan string s delimiterom " ",
        prije toga nadodat kljucnu rijec "log"
        taj string se parsira na strani servera i server provjerava jel zadovoljava username i password
        (odgovor od servera slusa LoginThread koji salje odgovor Login-u preko handle metode)
    */
    String username = UsernameLogin.getText();
    String password = PasswordLogin.getText();
    String user_pass = "******" + " " + username + " " + password;

    try {
      streamOut.writeUTF(user_pass);
    } catch (IOException ioe) {
      System.err.println("Sending error: " + ioe.getMessage());
      System.exit(0);
    }
  } // GEN-LAST:event_SignInButtonActionPerformed
Exemple #2
0
  /**
   * 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">//GEN-BEGIN:initComponents
  private void initComponents() {

    WelcomeLabel = new javax.swing.JLabel();
    UsernameLoginLabel = new javax.swing.JLabel();
    PasswordLoginLabel = new javax.swing.JLabel();
    UsernameLogin = new javax.swing.JTextField();
    SignInButton = new javax.swing.JButton();
    RegisterButton = new javax.swing.JButton();
    PasswordLogin = new javax.swing.JPasswordField();
    SetSocket = new javax.swing.JButton();

    setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

    WelcomeLabel.setFont(new java.awt.Font("Times New Roman", 0, 24)); // NOI18N
    WelcomeLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    WelcomeLabel.setText("Welcome!");

    UsernameLoginLabel.setText("Username:"******"Password:"******"Sign in");
    SignInButton.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            SignInButtonActionPerformed(evt);
          }
        });

    RegisterButton.setText("Register");
    RegisterButton.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            RegisterButtonActionPerformed(evt);
          }
        });

    PasswordLogin.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            PasswordLoginActionPerformed(evt);
          }
        });

    SetSocket.setText("Set Socket");
    SetSocket.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            SetSocketActionPerformed(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()
                    .addComponent(RegisterButton)
                    .addPreferredGap(
                        javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                        javax.swing.GroupLayout.DEFAULT_SIZE,
                        Short.MAX_VALUE)
                    .addComponent(SetSocket)
                    .addContainerGap())
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addGap(54, 54, 54)
                    .addGroup(
                        layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(UsernameLoginLabel)
                            .addComponent(PasswordLoginLabel))
                    .addGap(18, 18, 18)
                    .addGroup(
                        layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(
                                PasswordLogin,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                138,
                                Short.MAX_VALUE)
                            .addComponent(
                                WelcomeLabel,
                                javax.swing.GroupLayout.Alignment.TRAILING,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                138,
                                Short.MAX_VALUE)
                            .addComponent(
                                UsernameLogin,
                                javax.swing.GroupLayout.Alignment.TRAILING,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                138,
                                Short.MAX_VALUE))
                    .addContainerGap(111, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGroup(
                javax.swing.GroupLayout.Alignment.TRAILING,
                layout
                    .createSequentialGroup()
                    .addContainerGap(160, Short.MAX_VALUE)
                    .addComponent(SignInButton)
                    .addGap(150, 150, 150)));
    layout.setVerticalGroup(
        layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addGap(55, 55, 55)
                    .addComponent(
                        WelcomeLabel,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        41,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(18, 18, 18)
                    .addGroup(
                        layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(
                                UsernameLogin,
                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(UsernameLoginLabel))
                    .addGap(23, 23, 23)
                    .addGroup(
                        layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(PasswordLoginLabel)
                            .addComponent(
                                PasswordLogin,
                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGap(31, 31, 31)
                    .addComponent(SignInButton)
                    .addPreferredGap(
                        javax.swing.LayoutStyle.ComponentPlacement.RELATED, 28, Short.MAX_VALUE)
                    .addGroup(
                        layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(RegisterButton)
                            .addComponent(SetSocket))
                    .addContainerGap()));

    pack();
  } // </editor-fold>//GEN-END:initComponents