Advertisement
Guest User

BUTTON

a guest
May 22nd, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.71 KB | None | 0 0
  1. import java.awt.EventQueue;
  2. import javax.swing.JFrame;
  3. import javax.swing.JPanel;
  4. import javax.swing.border.EmptyBorder;
  5. import javax.swing.JTextField;
  6. import javax.swing.JLabel;
  7. import javax.swing.JOptionPane;
  8. import java.awt.Font;
  9. import java.awt.event.ActionEvent;
  10. import java.awt.event.ActionListener;
  11. import java.io.BufferedReader;
  12. import java.io.File;
  13. import java.io.FileNotFoundException;
  14. import java.io.FileReader;
  15. import java.io.IOException;
  16. import java.util.Scanner;
  17.  
  18. import javax.swing.JButton;
  19.  
  20. public class userLogin extends JFrame {
  21.  
  22. /**
  23. *
  24. */
  25. private static final long serialVersionUID = 1L;
  26. private JPanel contentPane;
  27. private JTextField user_tf;
  28. private JTextField pw_tf;
  29. private static userLogin frame;
  30. public static UserRegist registration;
  31.  
  32.  
  33.  
  34. /**
  35. * Launch the application.
  36. */
  37. public static void main(String[] args) throws IOException {
  38.  
  39. EventQueue.invokeLater(new Runnable() {
  40. public void run() {
  41. try {
  42. frame = new userLogin();
  43. frame.setVisible(true);
  44.  
  45. } catch (Exception e) {
  46. e.printStackTrace();
  47. }
  48. }
  49. });
  50. }
  51.  
  52. /**
  53. * Create the frame.
  54. */
  55. public userLogin() {
  56. setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  57. setBounds(100, 100, 383, 300);
  58. contentPane = new JPanel();
  59. contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
  60. setContentPane(contentPane);
  61. contentPane.setLayout(null);
  62.  
  63. user_tf = new JTextField();
  64. user_tf.setBounds(153, 80, 143, 20);
  65. contentPane.add(user_tf);
  66. user_tf.setColumns(10);
  67.  
  68. pw_tf = new JTextField();
  69. pw_tf.setFont(new Font("Webdings", Font.PLAIN, 11));
  70. pw_tf.setBounds(153, 139, 143, 20);
  71. contentPane.add(pw_tf);
  72. pw_tf.setColumns(10);
  73.  
  74. JLabel lblUsername = new JLabel("Username");
  75. lblUsername.setBounds(37, 83, 91, 14);
  76. contentPane.add(lblUsername);
  77.  
  78. JLabel lblPassword = new JLabel("Password");
  79. lblPassword.setBounds(37, 142, 91, 14);
  80. contentPane.add(lblPassword);
  81.  
  82. JLabel lblKamiLogin = new JLabel("KAMI Login");
  83. lblKamiLogin.setFont(new Font("Tahoma", Font.PLAIN, 18));
  84. lblKamiLogin.setBounds(37, 23, 313, 22);
  85. contentPane.add(lblKamiLogin);
  86.  
  87. JButton btnLogin = new JButton("Login");
  88. btnLogin.setBounds(207, 207, 89, 23);
  89. contentPane.add(btnLogin);
  90.  
  91. JButton btnRegister = new JButton("Register");
  92. btnRegister.setBounds(37, 207, 89, 23);
  93. contentPane.add(btnRegister);
  94.  
  95. class register implements ActionListener{
  96. public void actionPerformed (ActionEvent e){
  97. frame.dispose();
  98. registration = new UserRegist();
  99. registration.setVisible(true);
  100. }
  101. }
  102. btnRegister.addActionListener(new register());
  103.  
  104.  
  105.  
  106. }
  107.  
  108. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement