Advertisement
Guest User

Untitled

a guest
Nov 21st, 2014
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.61 KB | None | 0 0
  1. package presentationlayer;
  2.  
  3. import java.awt.BorderLayout;
  4. import java.awt.Font;
  5. import java.awt.event.ActionEvent;
  6. import java.awt.event.ActionListener;
  7. import java.sql.Date;
  8. import java.sql.SQLException;
  9. import java.text.DateFormat;
  10. import java.text.SimpleDateFormat;
  11. import java.util.ArrayList;
  12. import java.util.Calendar;
  13.  
  14. import javax.swing.ButtonGroup;
  15. import javax.swing.JButton;
  16. import javax.swing.JCheckBox;
  17. import javax.swing.JComboBox;
  18. import javax.swing.JFrame;
  19. import javax.swing.JLabel;
  20. import javax.swing.JOptionPane;
  21. import javax.swing.JRadioButton;
  22. import javax.swing.JTextArea;
  23. import javax.swing.JTextField;
  24.  
  25. import dataaccesslayer.Store;
  26.  
  27. import models.CandidateinfoBean;
  28.  
  29.  
  30. public class PersonalInformationGUI implements ActionListener
  31. {  
  32.     JFrame frame = new JFrame("Personal Information");
  33.     JLabel lblHeading = new JLabel("Personal Information");
  34.     JTextField tfFirstName = new JTextField();
  35.     JTextField tfLastName = new JTextField();
  36.     JTextField tfDateOfBirth = new JTextField();
  37.     JRadioButton rbSexMale = new JRadioButton("Male");
  38.     JRadioButton rbSexFemale = new JRadioButton("Female");
  39.     JTextArea taHobbies = new JTextArea();
  40.     JButton btnPrevious;
  41.     JButton btnNext;
  42.    
  43.     public PersonalInformationGUI()
  44.     {
  45.         frame.setSize(600, 600);
  46.         frame.setLocationRelativeTo(null);
  47.         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  48.         frame.setLayout(null);
  49.        
  50.         Font oldFont = frame.getFont();
  51.         Font font = new Font(null, 0, 30);
  52.         lblHeading.setFont(font);
  53.         lblHeading.setBounds(150, 50, 280, 40);
  54.         frame.add(lblHeading);
  55.        
  56.        
  57.         JLabel l1 = new JLabel("First Name :");
  58.         l1.setBounds(150, 140, 120, 30);
  59.         frame.add(l1);
  60.         tfFirstName.setBounds(300, 140, 120, 30);
  61.         frame.add(tfFirstName);
  62.        
  63.         JLabel l2 = new JLabel("Last Name :");
  64.         l2.setBounds(150, 180, 120, 30);
  65.         frame.add(l2);
  66.         tfLastName.setBounds(300, 180, 120, 30);
  67.         frame.add(tfLastName);
  68.        
  69.         JLabel l3 = new JLabel("Date of Birth :");
  70.         l3.setBounds(150, 220, 120, 30);
  71.         frame.add(l3);
  72.         tfDateOfBirth.setBounds(300, 220, 120, 30);
  73.         frame.add(tfDateOfBirth);
  74.         JLabel l6 = new JLabel("(yyyy/mm/dd)");
  75.         l6.setBounds(430, 220, 120, 30);
  76.         frame.add(l6);
  77.        
  78.         JLabel l4 = new JLabel("Sex :");
  79.         l4.setBounds(150, 260, 120, 30);
  80.         frame.add(l4);
  81.         rbSexMale.setBounds(300, 260, 60, 30);
  82.         frame.add(rbSexMale);
  83.         rbSexMale.setSelected(true);
  84.         rbSexFemale.setBounds(360, 260, 80, 30);
  85.         frame.add(rbSexFemale);
  86.         ButtonGroup group = new ButtonGroup();
  87.         group.add(rbSexMale);
  88.         group.add(rbSexFemale);
  89.        
  90.    
  91.         JLabel l5 = new JLabel("Hobbies :");
  92.         l5.setBounds(150, 300, 120, 30);
  93.         frame.add(l5);
  94.         taHobbies.setBounds(300, 300, 200, 70);
  95.         frame.add(taHobbies);
  96.        
  97.        
  98.         btnPrevious = new JButton("Back");
  99.         btnPrevious.setBounds(120, 480, 150, 40);
  100.         frame.add(btnPrevious);
  101.         btnPrevious.addActionListener(this);
  102.        
  103.         btnNext = new JButton("Next");
  104.         btnNext.setBounds(300, 480, 150, 40);
  105.         frame.add(btnNext);
  106.         btnNext.addActionListener(this);
  107.  
  108.         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  109.         frame.setVisible(true);
  110.        
  111.    
  112.         tfFirstName.setText(Store.candicate.getFirstName());
  113.         tfLastName.setText(Store.candicate.getLastName());
  114.         tfDateOfBirth.setText(Store.candicate.getDateOfBirth());
  115.         taHobbies.setText(Store.candicate.getHobbies());
  116.         if(Store.candicate.getSex().equals("Female"))
  117.             rbSexFemale.setSelected(true);
  118.         else
  119.             rbSexMale.setSelected(true);
  120.        
  121.     }
  122.  
  123.     @Override
  124.     public void actionPerformed(ActionEvent e)
  125.     {  
  126.         if(e.getSource() == btnPrevious)
  127.         {
  128.             MainGUI prev = new MainGUI();
  129.         }
  130.         else if(e.getSource() == btnNext)
  131.         {
  132.             if(tfFirstName.getText().equals("") ||
  133.                     tfFirstName.getText().equals("")||
  134.                     tfLastName.getText().equals("")||
  135.                     tfDateOfBirth.getText().equals("")||
  136.                     taHobbies.getText().equals(""))
  137.             {
  138.                 JOptionPane.showMessageDialog(null, "Please fill all the fields.");
  139.                 return;
  140.             }
  141.             DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
  142.             Calendar cal = Calendar.getInstance();
  143.             String c = dateFormat.format(cal.getTime());
  144.             //CandidateinfoBean candidate = new CandidateinfoBean(0, tfFirstName.getText(), tfLastName.getText(), tfDateOfBirth.getText(), rbSexMale.isSelected()?"":"", tfHobbies.getText(), c.toString(), "", "", "");
  145.             CandidateinfoBean candidate = new CandidateinfoBean(0, tfFirstName.getText(), tfLastName.getText(), tfDateOfBirth.getText(),rbSexMale.isSelected()?"Male":"Female", taHobbies.getText(), c, "", "", "");
  146.             Store.candicate = candidate;
  147.            
  148.             ContactInformationGUI next = new ContactInformationGUI();
  149.             frame.setVisible(false);
  150.         }
  151.         frame.setVisible(false);
  152.     }
  153. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement