Guest User

Untitled

a guest
Dec 25th, 2016
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.84 KB | None | 0 0
  1. package ems;
  2.  
  3. import java.awt.BorderLayout;
  4. import java.sql.*;
  5. import javax.swing.JOptionPane;
  6. import java.awt.EventQueue;
  7.  
  8. import javax.swing.JFrame;
  9. import javax.swing.JPanel;
  10. import javax.swing.border.EmptyBorder;
  11. import javax.swing.JButton;
  12. import java.awt.event.MouseAdapter;
  13. import java.awt.event.MouseEvent;
  14. import java.sql.Connection;
  15. import java.sql.DriverManager;
  16. import java.sql.ResultSet;
  17. import java.sql.Statement;
  18.  
  19. import javax.swing.JLabel;
  20. import javax.swing.JTextField;
  21. import javax.swing.JPasswordField;
  22. import javax.swing.ImageIcon;
  23. import javax.swing.border.TitledBorder;
  24.  
  25. import ems.MainWindow;
  26.  
  27. import java.awt.Font;
  28. import java.awt.event.ActionListener;
  29. import java.awt.event.ActionEvent;
  30. import java.awt.Color;
  31. import java.awt.Toolkit;
  32. import javax.swing.border.LineBorder;
  33.  
  34. public class LoginKlasa extends JFrame {
  35.  
  36.  
  37. private JPanel contentPane;
  38. private JTextField userInput;
  39. private JPasswordField passInput;
  40.  
  41. /**
  42. * Launch the application.
  43. */
  44. public static void main(String[] args) {
  45. EventQueue.invokeLater(new Runnable() {
  46. public void run() {
  47. try {
  48. LoginKlasa frame = new LoginKlasa();
  49. frame.setVisible(true);
  50. } catch (Exception e) {
  51. e.printStackTrace();
  52. }
  53. }
  54. });
  55. }
  56.  
  57. /**
  58. * Create the frame.
  59. */
  60. public LoginKlasa() {
  61.  
  62.  
  63.  
  64.  
  65.  
  66. setUndecorated(false);
  67. setIconImage(Toolkit.getDefaultToolkit().getImage(LoginKlasa.class.getResource("/images/burc.jpg")));
  68. setResizable(false);
  69. setVisible(true);
  70. setTitle("Employee Management System - Login");
  71. setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
  72. setBounds(100, 100, 450, 339);
  73. contentPane = new JPanel();
  74. contentPane.setBackground(Color.WHITE);
  75. contentPane.setBorder(new EmptyBorder(0, 0, 0, 0));
  76. setContentPane(contentPane);
  77. contentPane.setLayout(null);
  78.  
  79. JButton login = new JButton("LOGIN");
  80. login.addActionListener(new ActionListener() {
  81. public void actionPerformed(ActionEvent e) {
  82. }
  83. });
  84. login.addMouseListener(new MouseAdapter() {
  85. @Override
  86. public void mouseClicked(MouseEvent arg0) {
  87.  
  88.  
  89. String userText = userInput.getText();
  90. String passText = new String(passInput.getPassword());
  91. MyMethods mthds = new MyMethods();
  92.  
  93. JOptionPane.showMessageDialog(null, "You have logged in successfully.");
  94. MainWindow nw = new MainWindow();
  95.  
  96. setVisible(false);
  97.  
  98.  
  99. }
  100.  
  101. });
  102. login.setBounds(132, 260, 97, 25);
  103. contentPane.add(login);
  104.  
  105. JLabel lblUsername = new JLabel("Username");
  106. lblUsername.setBounds(114, 202, 89, 16);
  107. contentPane.add(lblUsername);
  108.  
  109. JLabel lblPassword = new JLabel("Password");
  110. lblPassword.setBounds(114, 231, 89, 16);
  111. contentPane.add(lblPassword);
  112.  
  113. userInput = new JTextField();
  114. userInput.setBounds(203, 202, 131, 22);
  115. contentPane.add(userInput);
  116. userInput.setColumns(10);
  117.  
  118. passInput = new JPasswordField();
  119. passInput.setColumns(10);
  120. passInput.setBounds(203, 231, 131, 22);
  121. contentPane.add(passInput);
  122.  
  123. JLabel label = new JLabel("");
  124. label.addMouseListener(new MouseAdapter() {
  125. @Override
  126. public void mouseClicked(MouseEvent arg0) {
  127. JOptionPane.showMessageDialog(null, "http://www.ibu.edu.ba/bs/");
  128. }
  129. });
  130. label.setIcon(new ImageIcon(LoginKlasa.class.getResource("/images/burc.jpg")));
  131. label.setBounds(134, 13, 180, 156);
  132. contentPane.add(label);
  133.  
  134. JLabel lblClickLogoFor = new JLabel("Click logo for more info");
  135. lblClickLogoFor.setFont(new Font("Tahoma", Font.PLAIN, 10));
  136. lblClickLogoFor.setBounds(167, 170, 133, 16);
  137. contentPane.add(lblClickLogoFor);
  138.  
  139. JButton btnExit = new JButton("EXIT");
  140. btnExit.addActionListener(new ActionListener() {
  141. public void actionPerformed(ActionEvent arg0) {
  142. System.exit(0);
  143. }
  144. });
  145. btnExit.setBounds(237, 261, 97, 25);
  146. contentPane.add(btnExit);
  147. }
  148. }
Add Comment
Please, Sign In to add comment