You are on page 1of 1

/* * To change this template, choose Tools | Templates * and open the template in the editor. */ import java.awt.

*; import java.awt.event.*; import javax.swing.*; import java.lang.String; class PASS extends JPanel { JPasswordField P1; String s=""; JButton B1; public PASS() { setLayout(new GridLayout(2,1)); setSize(400,500); P1 = new JPasswordField(""); B1 = new JButton("submit"); add(P1); add(B1); B1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { P1.setActionCommand("sunil"); if(P1.getText().equals("sunil")){ System.out.println("pass matched"); } else{System.out.println("pass not match");} } }); } } public class JavaApplication4 extends JPanel { /*public JavaApplication4(){ }*/ public static void main(String[] args) { JFrame j1 = new JFrame(); j1.setContentPane(new PASS()); j1.setVisible(true); j1.pack(); } }

You might also like