Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package presentationlayer;
- import java.awt.BorderLayout;
- import java.awt.Font;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.sql.Date;
- import java.sql.SQLException;
- import java.text.DateFormat;
- import java.text.SimpleDateFormat;
- import java.util.ArrayList;
- import java.util.Calendar;
- import javax.swing.ButtonGroup;
- import javax.swing.JButton;
- import javax.swing.JCheckBox;
- import javax.swing.JComboBox;
- import javax.swing.JFrame;
- import javax.swing.JLabel;
- import javax.swing.JOptionPane;
- import javax.swing.JRadioButton;
- import javax.swing.JTextArea;
- import javax.swing.JTextField;
- import dataaccesslayer.Store;
- import models.CandidateinfoBean;
- public class PersonalInformationGUI implements ActionListener
- {
- JFrame frame = new JFrame("Personal Information");
- JLabel lblHeading = new JLabel("Personal Information");
- JTextField tfFirstName = new JTextField();
- JTextField tfLastName = new JTextField();
- JTextField tfDateOfBirth = new JTextField();
- JRadioButton rbSexMale = new JRadioButton("Male");
- JRadioButton rbSexFemale = new JRadioButton("Female");
- JTextArea taHobbies = new JTextArea();
- JButton btnPrevious;
- JButton btnNext;
- public PersonalInformationGUI()
- {
- frame.setSize(600, 600);
- frame.setLocationRelativeTo(null);
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- frame.setLayout(null);
- Font oldFont = frame.getFont();
- Font font = new Font(null, 0, 30);
- lblHeading.setFont(font);
- lblHeading.setBounds(150, 50, 280, 40);
- frame.add(lblHeading);
- JLabel l1 = new JLabel("First Name :");
- l1.setBounds(150, 140, 120, 30);
- frame.add(l1);
- tfFirstName.setBounds(300, 140, 120, 30);
- frame.add(tfFirstName);
- JLabel l2 = new JLabel("Last Name :");
- l2.setBounds(150, 180, 120, 30);
- frame.add(l2);
- tfLastName.setBounds(300, 180, 120, 30);
- frame.add(tfLastName);
- JLabel l3 = new JLabel("Date of Birth :");
- l3.setBounds(150, 220, 120, 30);
- frame.add(l3);
- tfDateOfBirth.setBounds(300, 220, 120, 30);
- frame.add(tfDateOfBirth);
- JLabel l6 = new JLabel("(yyyy/mm/dd)");
- l6.setBounds(430, 220, 120, 30);
- frame.add(l6);
- JLabel l4 = new JLabel("Sex :");
- l4.setBounds(150, 260, 120, 30);
- frame.add(l4);
- rbSexMale.setBounds(300, 260, 60, 30);
- frame.add(rbSexMale);
- rbSexMale.setSelected(true);
- rbSexFemale.setBounds(360, 260, 80, 30);
- frame.add(rbSexFemale);
- ButtonGroup group = new ButtonGroup();
- group.add(rbSexMale);
- group.add(rbSexFemale);
- JLabel l5 = new JLabel("Hobbies :");
- l5.setBounds(150, 300, 120, 30);
- frame.add(l5);
- taHobbies.setBounds(300, 300, 200, 70);
- frame.add(taHobbies);
- btnPrevious = new JButton("Back");
- btnPrevious.setBounds(120, 480, 150, 40);
- frame.add(btnPrevious);
- btnPrevious.addActionListener(this);
- btnNext = new JButton("Next");
- btnNext.setBounds(300, 480, 150, 40);
- frame.add(btnNext);
- btnNext.addActionListener(this);
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- frame.setVisible(true);
- tfFirstName.setText(Store.candicate.getFirstName());
- tfLastName.setText(Store.candicate.getLastName());
- tfDateOfBirth.setText(Store.candicate.getDateOfBirth());
- taHobbies.setText(Store.candicate.getHobbies());
- if(Store.candicate.getSex().equals("Female"))
- rbSexFemale.setSelected(true);
- else
- rbSexMale.setSelected(true);
- }
- @Override
- public void actionPerformed(ActionEvent e)
- {
- if(e.getSource() == btnPrevious)
- {
- MainGUI prev = new MainGUI();
- }
- else if(e.getSource() == btnNext)
- {
- if(tfFirstName.getText().equals("") ||
- tfFirstName.getText().equals("")||
- tfLastName.getText().equals("")||
- tfDateOfBirth.getText().equals("")||
- taHobbies.getText().equals(""))
- {
- JOptionPane.showMessageDialog(null, "Please fill all the fields.");
- return;
- }
- DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
- Calendar cal = Calendar.getInstance();
- String c = dateFormat.format(cal.getTime());
- //CandidateinfoBean candidate = new CandidateinfoBean(0, tfFirstName.getText(), tfLastName.getText(), tfDateOfBirth.getText(), rbSexMale.isSelected()?"":"", tfHobbies.getText(), c.toString(), "", "", "");
- CandidateinfoBean candidate = new CandidateinfoBean(0, tfFirstName.getText(), tfLastName.getText(), tfDateOfBirth.getText(),rbSexMale.isSelected()?"Male":"Female", taHobbies.getText(), c, "", "", "");
- Store.candicate = candidate;
- ContactInformationGUI next = new ContactInformationGUI();
- frame.setVisible(false);
- }
- frame.setVisible(false);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement