Advertisement
Guest User

view

a guest
Aug 8th, 2012
19
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.11 KB | None | 0 0
  1. package view;
  2.  
  3. import java.awt.BorderLayout;
  4.  
  5. public class LogInView extends JFrame {
  6.  
  7.    
  8.     private static final long serialVersionUID = 3238505063965559438L;
  9.     private JPanel contentPane;
  10.     private JTextField nameTextField;
  11.     private JTextField passwordTextField;
  12.     private static InfoQueries infoQueries;
  13.  
  14.     /**
  15.      * Launch the application.
  16.      */
  17.     public static void main(String[] args) {
  18.         EventQueue.invokeLater(new Runnable() {
  19.             public void run() {
  20.                 try {
  21.                     LogInView frame = new LogInView();
  22.                     frame.setVisible(true);
  23.                     infoQueries = new InfoQueries();
  24.                 } catch (Exception e) {
  25.                     e.printStackTrace();
  26.                 }
  27.             }
  28.         });
  29.     }
  30.  
  31.     /**
  32.      * Create the frame.
  33.      */
  34.     public LogInView() {
  35.         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  36.         setBounds(100, 100, 450, 300);
  37.         contentPane = new JPanel();
  38.         contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
  39.         contentPane.setLayout(new BorderLayout(0, 0));
  40.         setContentPane(contentPane);
  41.        
  42.         JPanel panel = new JPanel();
  43.         contentPane.add(panel, BorderLayout.CENTER);
  44.         panel.setLayout(null);
  45.        
  46.         nameTextField = new JTextField();
  47.         nameTextField.setBounds(142, 74, 86, 20);
  48.         panel.add(nameTextField);
  49.         nameTextField.setColumns(10);
  50.        
  51.         passwordTextField = new JTextField();
  52.         passwordTextField.setBounds(142, 124, 86, 20);
  53.         panel.add(passwordTextField);
  54.         passwordTextField.setColumns(10);
  55.        
  56.         JButton btnSignup = new JButton("SignUp");
  57.         btnSignup.addActionListener(new ActionListener() {
  58.            
  59.  
  60.             public void actionPerformed(ActionEvent arg0) {
  61.                 infoQueries.addPerson(
  62.                         nameTextField.getText(), passwordTextField.getText());
  63.             }
  64.         });
  65.         btnSignup.setBounds(282, 73, 89, 23);
  66.         panel.add(btnSignup);
  67.        
  68.         JButton btnLogIn = new JButton("Log In");
  69.         btnLogIn.addActionListener(new ActionListener() {
  70.             public void actionPerformed(ActionEvent arg0) {
  71.             boolean results = infoQueries.getPeopleByUsername(nameTextField.getText(),passwordTextField.getText());
  72.             if(results==true)System.out.print("yes");
  73.             else System.out.print("No");
  74.             }
  75.         });
  76.         btnLogIn.setBounds(282, 123, 89, 23);
  77.         panel.add(btnLogIn);
  78.     }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement