import javax.swing.*;
import java.awt.*;
import java.awt.event .*;
import java.io.*;
import javax.swing.border.*;
public class Login implements ActionListener
{
JFrame frame;
JPanel jp;
JLabel lb;
JLabel imglb;
JPasswordField pw;
Login()
{
frame=new JFrame("Login");
jp=new JPanel();
lb=new JLabel("Enter Password:");
imglb=new JLabel(new ImageIcon(".//bg.gif"));
pw=new JPasswordField();
pw.setFont(new Font("comic sans ms",Font.BOLD,18));
jp.setLayout(null);
lb.setBounds(265,30,150,30);
lb.setForeground(Color.white);
lb.setFont(new Font("Comic Sans ms",Font.BOLD,18));
imglb.setBounds(0,0,480,200);
Border blackline = BorderFactory.createLineBorder(Color.red);
imglb.setBorder(blackline);
pw.setBounds(250,60,180,30);
pw.addActionListener(this);
jp.add(lb);
jp.add(pw);
jp.add(imglb);
frame.add(jp);
frame.setSize(480,200);
frame.setLocation(350,200);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setResizable(false);
frame.setUndecorated(true);
frame.setVisible(true);
}
public static void main(String... s)
{
new Login();
}
public void actionPerformed(ActionEvent e)
{
if(String.valueOf(pw.getPassword()).equals("admin"))
{
JOptionPane.showMessageDialog(null,"Password is right,Moving to the next Frame","Sucess",JOptionPane.INFORMATION_MESSAGE);
System.exit(0);
}
else
{
JOptionPane.showMessageDialog(null,"Password is Wrong,Re-enter","Sucess",JOptionPane.ERROR_MESSAGE);
pw.requestFocus();
}
}
}
output:
0 comments:
Post a Comment