package  da;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

class MyGUI
    extends  JFrame
    implements ActionListener
{
    Container Container;
    JLabel Title, FirstName, MiddleName, LastName, ZipCode, Email, MobileNumber, Address, Gender, DateofBirth, ResetB;
    JTextField textFieldFirstName, textFieldMiddleName, textFieldLastName,  textFieldMobileNumber,  textFieldAddress,
            textFieldZip,  textFieldEmail;
    JRadioButton Male, Female, Binary;
    ButtonGroup GenderButtons;
    JComboBox Day, Month, Year;
    JCheckBox Term;
    JButton Submit, Reset;
    JTextArea OutputText;

    Integer Days[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
                        26, 27, 28, 29, 30, 31};

    String Months[] = {"January", "February", "March","April", "May", "June", "July", "August",
                       "September", "October", "November", "December"};

    String Years[] = {"1990", "1991", "1992", "1993", "1994", "1995", "1996", "1997", "1998", "1999", "2000",
                     "2001", "2002", "2003", "2004", "2005", "2006", "2007", "2008", "2009", "2010",
                     "2011", "2012", "2013", "2014", "2015", "2016", "2017", "2018", "2019", "2020",
                     "2021", "2022", "2023", "2024", "2025", "2026", "2027", "2028", "2029", "2030",};

    public MyGUI()
    {
        setTitle("Online Registration Form");
        setBounds(100, 180, 1366, 768);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        setResizable(false);

        Container = getContentPane();
        Container.setLayout(null);

        Title = new JLabel("Registration Form");
        Title.setFont(new Font("Castellar", Font.BOLD,30));
        Title.setSize(400, 30);
        Title.setLocation(250, 30);
        Container.add(Title);

        FirstName = new JLabel("First Name");
        FirstName.setFont(new Font("Times New Roman", Font.BOLD,20));
        FirstName.setSize(150, 20);
        FirstName.setLocation(150, 100);
        Container.add(FirstName);

        MiddleName = new JLabel("Middle Name");
        MiddleName.setFont(new Font("Times New Roman", Font.BOLD,20));
        MiddleName.setSize(150, 20);
        MiddleName.setLocation(150, 130);
        Container.add(MiddleName);

        LastName = new JLabel("Last Name");
        LastName.setFont(new Font("Times New Roman", Font.BOLD,20));
        LastName.setSize(300, 20);
        LastName.setLocation(150, 160);
        Container.add(LastName);

        MobileNumber = new JLabel("Mobile Number");
        MobileNumber.setFont(new Font("Times New Roman", Font.BOLD,20));
        MobileNumber.setSize(300, 20);
        MobileNumber.setLocation(150, 190);
        Container.add(MobileNumber);

        Address = new JLabel("Address");
        Address.setFont(new Font("Times New Roman", Font.BOLD,20));
        Address.setSize(300, 20);
        Address.setLocation(150, 220);
        Container.add(Address);

        ZipCode = new JLabel("Zip Code");
        ZipCode.setFont(new Font("Times New Roman", Font.BOLD,20));
        ZipCode.setSize(300, 20);
        ZipCode.setLocation(150, 250);
        Container.add(ZipCode);

        Email = new JLabel("Email Address");
        Email.setFont(new Font("Times New Roman", Font.BOLD,20));
        Email.setSize(300, 20);
        Email.setLocation(150, 280);
        Container.add(Email);



        Gender = new JLabel("Gender");
        Gender.setFont(new Font("Times New Roman", Font.BOLD,20));
        Gender.setSize(500, 20);
        Gender.setLocation(300, 310);
        Container.add(Gender);

        Male = new JRadioButton("Male");
        Male.setFont(new Font("Arial", Font.BOLD,15));
        Male.setSelected(true);
        Male.setSize(60, 20);
        Male.setLocation(380, 310);
        Container.add(Male);

        Female = new JRadioButton("Female");
        Female.setFont(new Font("Arial", Font.BOLD,15));
        Female.setSelected(false);
        Female.setSize(75, 20);
        Female.setLocation(440, 310);
        Container.add(Female);

        Binary = new JRadioButton("Binary");
        Binary.setFont(new Font("Arial", Font.BOLD,15));
        Binary.setSelected(false);
        Binary.setSize(80, 20);
        Binary.setLocation(520, 310);
        Container.add(Binary);

        GenderButtons = new ButtonGroup();
        GenderButtons.add(Male);
        GenderButtons.add(Female);
        GenderButtons.add(Binary);

        DateofBirth = new JLabel("Date of Birth");
        DateofBirth.setFont(new Font("Times New Roman", Font.BOLD,20));
        DateofBirth.setSize(120, 20);
        DateofBirth.setLocation(300, 340);
        Container.add(DateofBirth);

        Day = new JComboBox(Days);
        Day.setFont (new Font("Arial", Font.PLAIN, 15));
        Day.setSize(50, 20);
        Day.setLocation(440,340);
        Container.add(Day);

        Month = new JComboBox(Months);
        Month.setFont (new Font("Arial", Font.PLAIN, 15));
        Month.setSize(100, 20);
        Month.setLocation(490,340);
        Container.add(Month);

        Year = new JComboBox(Years);
        Year.setFont (new Font("Arial", Font.PLAIN, 15));
        Year.setSize(100, 20);
        Year.setLocation(590, 340);
        Container.add(Year);

        Term = new JCheckBox("Accept Terms and Conditions");
        Term.setFont (new Font("Arial", Font.PLAIN, 15));
        Term.setSize(600, 20);
        Term.setLocation(380, 380);
        Container.add(Term);


        Submit = new JButton("Submit");
        Submit.setFont (new Font("Arial", Font.PLAIN, 15));
        Submit.setSize(100, 20);
        Submit.setLocation(370, 420);
        Submit.addActionListener(this);
        Container.add(Submit);

        Reset = new JButton("Reset");
        Reset.setFont(new Font("Arial", Font.PLAIN, 15));
        Reset.setSize(100, 20);
        Reset.setLocation(530,420);
        Reset.addActionListener(this);
        Container.add(Reset);

        OutputText = new JTextArea();
        OutputText.setFont(new Font("Arial", Font.ITALIC, 15));
        OutputText.setSize(750, 130);
        OutputText.setLocation(80, 450);
        OutputText.setLineWrap(false);
        OutputText.setEditable(false);
        Container.add(OutputText);

        //ito na yung part na pwedi na mag enter ng infos or text si user
        textFieldFirstName = new JTextField();
        textFieldFirstName.setFont(new Font("Times New Roman", Font.PLAIN, 20));
        textFieldFirstName.setSize(500, 20);
        textFieldFirstName.setLocation(300, 100);
        Container.add(textFieldFirstName);

        textFieldMiddleName = new JTextField();
        textFieldMiddleName.setFont(new Font("Times New Roman", Font.PLAIN, 20));
        textFieldMiddleName.setSize(500, 20);
        textFieldMiddleName.setLocation(300, 130);
        Container.add(textFieldMiddleName);

        textFieldLastName = new JTextField();
        textFieldLastName.setFont(new Font("Times New Roman", Font.PLAIN, 20));
        textFieldLastName.setSize(500, 20);
        textFieldLastName.setLocation(300, 160);
        Container.add(textFieldLastName);

        textFieldMobileNumber = new JTextField();
        textFieldMobileNumber.setFont(new Font("Times New Roman", Font.PLAIN, 20));
        textFieldMobileNumber.setSize(500, 20);
        textFieldMobileNumber.setLocation(300, 190);
        Container.add(textFieldMobileNumber);

        textFieldAddress = new JTextField();
        textFieldAddress.setFont(new Font("Times New Roman", Font.PLAIN, 20));
        textFieldAddress.setSize(500, 20);
        textFieldAddress.setLocation(300, 220);
        Container.add(textFieldAddress);

        textFieldZip = new JTextField();
        textFieldZip.setFont(new Font("Times New Roman", Font.PLAIN, 20));
        textFieldZip.setSize(500, 20);
        textFieldZip.setLocation(300, 250);
        Container.add(textFieldZip);

        textFieldEmail = new JTextField();
        textFieldEmail.setFont(new Font("Times New Roman", Font.PLAIN, 20));
        textFieldEmail.setSize(500, 20);
        textFieldEmail.setLocation(300, 280);
        Container.add(textFieldEmail);

        ResetB = new JLabel("");
        ResetB.setFont(new Font("Arial", Font.PLAIN, 20));
        ResetB.setSize(500, 25);
        ResetB.setLocation(100, 500);
        Container.add(ResetB);

        setVisible(true);

    }

public void actionPerformed(ActionEvent e)
{
    if (e.getSource() == Submit)
    {
        if(Term.isSelected())
        {
            String Genda;
            String data = "Fullname: " + textFieldFirstName.getText() + " " + textFieldMiddleName.getText()
                    + " " + textFieldLastName.getText() + "\n" + "Mobile Number: " + textFieldMobileNumber.getText() + "\n";
            if (Male.isSelected())
                Genda = "Gender: Male" + "\n";

            else if (Female.isSelected())
                Genda = "Gender: Female" + "\n";

            else
                Genda = "Gender: Binary" + "\n";

            String DoB = "Date of Birth: " + Month.getSelectedItem() + ", " + Day.getSelectedItem() + ", "
                    + Year.getSelectedItem() + "\n";

            String Addrss = "Address: " + textFieldAddress.getText() + "\n";
            String Zcode = "Zip Code: " + textFieldZip.getText() + "\n";
            String EmailAdd = "Email Address: " + textFieldEmail.getText() + "\n";

            OutputText.setText(data + Genda + DoB + Addrss + Zcode + EmailAdd);

        }
        else
        {
            ResetB.setText("Error");
        }
    }
         else if (e.getSource() == Reset)
         {
        String def = "";
        textFieldEmail.setText(def);
        textFieldFirstName.setText(def);
        textFieldMiddleName.setText(def);
        textFieldLastName.setText(def);
        textFieldAddress.setText(def);
        textFieldZip.setText(def);
        textFieldMobileNumber.setText(def);
        OutputText.setText(def);
          Term.setSelected(false);
         Day.setSelectedIndex(0);
          Month.setSelectedIndex(0);
            Year.setSelectedIndex(0);
             ResetB.setText(def);


         }


    }

}

class Main{
    public static  void main(String[] args) throws Exception
    {
        MyGUI gui = new MyGUI();
    }
}

Copyright © 2012 ITHUB / Template by : Ric Torregoza