import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.PrintStream;
import java.net.Socket;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import javax.swing.UIManager;

public class PeerLogin extends JFrame
{
  private JLabel lbl_title;
  private JLabel lbl_img;
  private JLabel lbl_img1;
  private JLabel lbl_pname;
  private JLabel lbl_pass;
  private JTextField txt_pname;
  private JPasswordField txt_pass;
  private JButton btn_login;
  private JButton btn_exit;
  private JPanel contentPane;
  Sysname sn = new Sysname();

  public PeerLogin()
  {
    initializeComponent();

    setVisible(true);
  }

  private void initializeComponent()
  {
    this.lbl_title = new JLabel();
    this.lbl_img = new JLabel();
    this.lbl_img1 = new JLabel();
    this.lbl_pname = new JLabel();
    this.txt_pname = new JTextField();
    this.lbl_pass = new JLabel();
    this.txt_pass = new JPasswordField();
    this.btn_login = new JButton();
    this.btn_exit = new JButton();
    this.contentPane = ((JPanel)getContentPane());

    this.lbl_title.setIcon(new ImageIcon("Peer Images\\login.jpeg"));

    this.lbl_img.setIcon(new ImageIcon("Peer Images\\p1.jpeg"));

    this.lbl_img1.setIcon(new ImageIcon("Peer Images\\p2.jpeg"));

    this.lbl_pname.setText("Peer Name");
    this.lbl_pname.setFont(new Font("Monotype Corsiva", 1, 20));

    this.txt_pname.addActionListener(new ActionListener()
    {
      public void actionPerformed(ActionEvent paramActionEvent) {
        PeerLogin.this.txt_pname_actionPerformed(paramActionEvent);
      }
    });
    this.lbl_pass.setText("Password");
    this.lbl_pass.setFont(new Font("Monotype Corsiva", 1, 20));

    this.txt_pass.addActionListener(new PeerLogin.2(this));

    this.btn_login.setText("Login");
    this.btn_login.addActionListener(new PeerLogin.3(this));

    this.btn_exit.setText("Exit");
    this.btn_exit.addActionListener(new PeerLogin.4(this));

    this.contentPane.setLayout(null);

    addComponent(this.contentPane, this.lbl_img, 1, 2, 100, 90);
    addComponent(this.contentPane, this.lbl_title, 100, 2, 100, 90);
    addComponent(this.contentPane, this.lbl_img1, 200, 2, 100, 90);
    addComponent(this.contentPane, this.lbl_pname, 50, 110, 100, 18);
    addComponent(this.contentPane, this.txt_pname, 170, 110, 100, 22);
    addComponent(this.contentPane, this.lbl_pass, 50, 140, 100, 18);
    addComponent(this.contentPane, this.txt_pass, 170, 140, 100, 22);
    addComponent(this.contentPane, this.btn_login, 50, 200, 83, 28);
    addComponent(this.contentPane, this.btn_exit, 180, 200, 83, 28);

    setTitle("PeerLogin - extends JFrame");
    setLocation(new Point(0, 0));
    setSize(new Dimension(310, 300));
  }

  private void addComponent(Container paramContainer, Component paramComponent, int paramInt1, int 

paramInt2, int paramInt3, int paramInt4)
  {
    paramComponent.setBounds(paramInt1, paramInt2, paramInt3, paramInt4);
    paramContainer.add(paramComponent);
  }

  private void txt_pname_actionPerformed(ActionEvent paramActionEvent)
  {
    System.out.println("\ntxt_pname_actionPerformed(ActionEvent e) called.");
  }

  private void txt_pass_actionPerformed(ActionEvent paramActionEvent)
  {
    System.out.println("\njPasswordField1_actionPerformed(ActionEvent e) called.");
  }

  private void btn_login_actionPerformed(ActionEvent paramActionEvent)
  {
    String str1 = ""; String str2 = ""; String str3 = ""; String str4 = ""; String str5 = "";
    try {
      str1 = this.txt_pname.getText();
      str4 = this.txt_pass.getText();
      System.out.println("pname:" + str1);
      System.out.println("pass:" + str4);

      if ((str1.equals("")) || (str4.equals("")))
      {
        JOptionPane.showMessageDialog(this, "Enter PeerInformation");
      }
      else
      {
        str2 = this.sn.getServerIP();
        Socket localSocket1 = new Socket(str2, 4200);
        DataOutputStream localDataOutputStream1 = new DataOutputStream(localSocket1.getOutputStream());
        localDataOutputStream1.writeUTF("chkuser");
        localDataOutputStream1.writeUTF(str1 + "@" + str4);
        DataInputStream localDataInputStream1 = new DataInputStream(localSocket1.getInputStream());
        str5 = localDataInputStream1.readUTF();
        System.out.println("res:" + str5);
        if (str5.equals("ValidUser"))
        {
          JOptionPane.showMessageDialog(this, "ValidPeer");
          Socket localSocket2 = new Socket(str2, 4200);
          DataOutputStream localDataOutputStream2 = new DataOutputStream(localSocket2.getOutputStream

());
          localDataOutputStream2.writeUTF("GenSign");
          localDataOutputStream2.writeUTF(str1);
          DataInputStream localDataInputStream2 = new DataInputStream(localSocket2.getInputStream());
          str3 = localDataInputStream2.readUTF();
          System.out.println("res:" + str3);
          setVisible(false);
          new Peer(str1);
          new Load();
        }
        else if (str5.equals("InValidUser"))
        {
          JOptionPane.showMessageDialog(this, "PeerName Or Password Incorrect ");
        }
        else
        {
          JOptionPane.showMessageDialog(this, "Peer Doesnot Exist");
        }
      }
    }
    catch (Exception localException) {
      localException.printStackTrace();
    }
  }

  private void btn_exit_actionPerformed(ActionEvent paramActionEvent)
  {
    System.out.println("\nbtn_exit_actionPerformed(ActionEvent e) called.");
  }

  public static void main(String[] paramArrayOfString)
  {
    JFrame.setDefaultLookAndFeelDecorated(true);
    JDialog.setDefaultLookAndFeelDecorated(true);
    try
    {
      UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
    }
    catch (Exception localException)
    {
      System.out.println("Failed loading L&F: ");
      System.out.println(localException);
    }
    new PeerLogin();
  }
}

What on earth are you trying to do with this code?

new PeerLogin.2(this)
commented: lmfao +8
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.