Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package javastud;
- import java.awt.BorderLayout;
- import java.awt.Color;
- import java.awt.EventQueue;
- import javax.swing.JFrame;
- import javax.swing.JPanel;
- import javax.swing.border.EmptyBorder;
- import dao.UserDao;
- import dao.UserDaoImpl;
- import javax.swing.JLabel;
- import java.awt.Font;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import javax.swing.JTextField;
- import javax.swing.JButton;
- import javax.swing.ImageIcon;
- import javax.swing.JPasswordField;
- public class LOGIInform extends JFrame {
- private JPanel contentPane;
- private JLabel lblStudentMangementSystem;
- private JLabel lblName;
- private JTextField usernameTXT;
- private JLabel lblPassword;
- private JButton btnLogIn;
- private JButton btnNewButton;
- private JLabel lblNewLabel;
- private JPasswordField passwordField;
- /**
- * Launch the application.
- */
- public static void main(String[] args) {
- EventQueue.invokeLater(new Runnable() {
- public void run() {
- try {
- LOGIInform frame = new LOGIInform();
- frame.setVisible(true);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- });
- }
- /**
- * Create the frame.
- */
- public LOGIInform() {
- setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- setBounds(100, 100, 807, 706);
- contentPane = new JPanel();
- contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
- setContentPane(contentPane);
- contentPane.setLayout(null);
- contentPane.add(getLblStudentMangementSystem());
- contentPane.add(getLblName());
- contentPane.add(getUsernameTXT());
- contentPane.add(getLblPassword());
- contentPane.add(getBtnLogIn());
- contentPane.add(getBtnNewButton());
- contentPane.add(getLblNewLabel());
- contentPane.add(getPasswordField());
- }
- private JLabel getLblStudentMangementSystem() {
- if (lblStudentMangementSystem == null) {
- lblStudentMangementSystem = new JLabel("STUDENT MANGEMENT SYSTEM ");
- lblStudentMangementSystem.setFont(new Font("Tahoma", Font.PLAIN, 23));
- lblStudentMangementSystem.setBounds(201, 0, 353, 57);
- }
- return lblStudentMangementSystem;
- }
- private JLabel getLblName() {
- if (lblName == null) {
- lblName = new JLabel("Username");
- lblName.setFont(new Font("Tahoma", Font.BOLD, 20));
- lblName.setBounds(215, 370, 109, 32);
- }
- return lblName;
- }
- private JTextField getUsernameTXT() {
- if (usernameTXT == null) {
- usernameTXT = new JTextField();
- usernameTXT.setBounds(347, 378, 135, 22);
- usernameTXT.setColumns(10);
- }
- return usernameTXT;
- }
- private JLabel getLblPassword() {
- if (lblPassword == null) {
- lblPassword = new JLabel("Password");
- lblPassword.setFont(new Font("Tahoma", Font.BOLD, 20));
- lblPassword.setBounds(226, 405, 109, 32);
- }
- return lblPassword;
- }
- private JButton getBtnLogIn() {
- if (btnLogIn == null) {
- btnLogIn = new JButton("Log In");
- btnLogIn.setBounds(256, 490, 109, 25);
- btnLogIn.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- UserDao userDao=new UserDaoImpl();
- String username=usernameTXT.getText();
- String password=new String(passwordField.getPassword());
- boolean isValidUser=userDao.validateUser(username,password);
- if(isValidUser) {
- studentform studform=new studentform();
- studform.setVisible(true);
- }else {
- usernameTXT.setBackground(Color.PINK);
- passwordField.setBackground(Color.PINK);
- }
- }
- });
- }
- return btnLogIn;
- }
- private JButton getBtnNewButton() {
- if (btnNewButton == null) {
- btnNewButton = new JButton("Cancel");
- btnNewButton.setBounds(365, 490, 109, 25);
- }
- return btnNewButton;
- }
- private JLabel getLblNewLabel() {
- if (lblNewLabel == null) {
- lblNewLabel = new JLabel("New label");
- lblNewLabel.setIcon(new ImageIcon("C:\\Users\\Rupesh\\Downloads\\user-logo.217a36f841be.png"));
- lblNewLabel.setBounds(134, 57, 479, 286);
- }
- return lblNewLabel;
- }
- private JPasswordField getPasswordField() {
- if (passwordField == null) {
- passwordField = new JPasswordField();
- passwordField.setBounds(347, 413, 135, 22);
- }
- return passwordField;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement