package login;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import java.awt.Font;
import java.awt.Color;
import java.awt.SystemColor;
import javax.swing.JTextField;
import calculator.calci;
import javax.swing.JPasswordField;
import javax.swing.JButton;
import javax.swing.JSeparator;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class Login_System {
private JFrame frame;
private JTextField textField;
private JPasswordField passwordField;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Login_System window = new Login_System();
window.frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the application.
*/
public Login_System() {
initialize();
}
/**
* Initialize the contents of the frame.
*/
private void initialize() {
frame = new JFrame();
frame.setForeground(Color.LIGHT_GRAY);
frame.setBounds(100, 100, 402, 295);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(null);
JLabel lblNewLabel = new JLabel("USER LOGIN");
lblNewLabel.setForeground(SystemColor.controlText);
lblNewLabel.setFont(new Font("SansSerif", Font.BOLD, 50));
lblNewLabel.setBounds(82, 11, 368, 44);
frame.getContentPane().add(lblNewLabel);
JLabel lblNewLabel_1 = new JLabel("USERNAME");
lblNewLabel_1.setFont(new Font("SansSerif", Font.BOLD, 15));
lblNewLabel_1.setBounds(41, 93, 92, 24);
frame.getContentPane().add(lblNewLabel_1);
JLabel lblNewLabel_2 = new JLabel("PASSWORD");
lblNewLabel_2.setFont(new Font("SansSerif", Font.BOLD, 15));
lblNewLabel_2.setBounds(41, 143, 92, 31);
frame.getContentPane().add(lblNewLabel_2);
textField = new JTextField();
textField.setFont(new Font("Tahoma", Font.BOLD, 15));
textField.setBounds(167, 95, 152, 20);
frame.getContentPane().add(textField);
textField.setColumns(10);
passwordField = new JPasswordField();
passwordField.setFont(new Font("Tahoma", Font.BOLD, 15));
passwordField.setBounds(167, 148, 152, 20);
frame.getContentPane().add(passwordField);
JButton btnLogin = new JButton("LOGIN");
btnLogin.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
String password = passwordField.getText();
String username = textField.getText();
if(password.contains("king")&& username.contains("user"))
{
passwordField.setText(null);
textField.setText(null);
JOptionPane.showMessageDialog(null, "LOGIN SUCCSES","LOGIN SUCCSES",JOptionPane.ERROR_MESSAGE);
}
else
{
JOptionPane.showMessageDialog(null, "WRONG SOMETHING","LOGIN ERROR",JOptionPane.ERROR_MESSAGE);
}
}
});
btnLogin.setFont(new Font("Tahoma", Font.BOLD, 15));
btnLogin.setBounds(41, 205, 92, 31);
frame.getContentPane().add(btnLogin);
JButton btnNewButton = new JButton("RESET");
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
textField.setText(null);
passwordField.setText(null);
}
});
btnNewButton.setFont(new Font("Tahoma", Font.BOLD, 15));
btnNewButton.setBounds(209, 205, 92, 31);
frame.getContentPane().add(btnNewButton);
JSeparator separator = new JSeparator();
separator.setBounds(10, 192, 466, 2);
frame.getContentPane().add(separator);
JSeparator separator_1 = new JSeparator();
separator_1.setBounds(10, 66, 466, 2);
frame.getContentPane().add(separator_1);
}
}
Windows App Login with java programing
Below is a complete script for Java code, creating a login app with Eclipse
Share this article :

0 comments:
Post a Comment
Please fill your name to response.