0% found this document useful (0 votes)
10 views6 pages

Follow The Instructions Given On Each Item. Paste Your and - Use The Format Given and Avoid Using Another Format

The document outlines a laboratory activity for an Integrative Programming and Technologies course, requiring students to create a survey form using Java Swing components. It specifies the required components, including labels, text fields, radio buttons, combo boxes, and buttons, along with their functionalities for submission, clearing, and exiting. The provided code demonstrates the implementation of the graphical user interface and the associated actions for each button.

Uploaded by

navarettenoel05
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views6 pages

Follow The Instructions Given On Each Item. Paste Your and - Use The Format Given and Avoid Using Another Format

The document outlines a laboratory activity for an Integrative Programming and Technologies course, requiring students to create a survey form using Java Swing components. It specifies the required components, including labels, text fields, radio buttons, combo boxes, and buttons, along with their functionalities for submission, clearing, and exiting. The provided code demonstrates the implementation of the graphical user interface and the associated actions for each button.

Uploaded by

navarettenoel05
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Name: JAVIER, ALYSSA ROSE F.

Year & Block: 2 - B


Subject: IPT101 – Integrative Programming and Technologies 1

IPT101 – LABORATORY ACTIVITY 3


Directions: Follow the instructions given on each item. Paste your ACTUAL CODE
and SCREENSHOT THE EXACT OUTPUT. Use the format given and avoid using another
format.

Form Requirements:
9 – JLabel
4 - JTextField
4 – JradioButton
2 - JCombobox
3 – JButton

Actual Graphical User Interface:

Samuel F. Camorongan
Faculty, College of Information Technology
Function for button Submit:

Take note: For the button submit, once the user click the button OK at the dialog
box it will automatically clear the user input.

Function for button Clear:

Function for button Exit:

Samuel F. Camorongan
Faculty, College of Information Technology
INSERT THE ACTUAL CODE:
package JAVIER_SURVEYFORM;

import java.awt.EventQueue;
import javax.swing.*;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class JAVIER_SURVEYFORM {

private JFrame frame;


private JTextField Name, Address, Age, StudentID;
private JComboBox<String> Course, YearBlock;
private JRadioButton Enrolled, NotEnrolled, Female, Male;
private JLabel lblStatus;
private JLabel lblGender;

public static void main(String[] args) {


EventQueue.invokeLater(new Runnable() {
public void run() {
try {
JAVIER_SURVEYFORM window = new JAVIER_SURVEYFORM();
window.frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}

public JAVIER_SURVEYFORM() {
initialize();
}

private void initialize() {


frame = new JFrame();
frame.setBounds(100, 100, 690, 424);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(null);

JLabel SF = new JLabel("SURVEY FORM");


SF.setFont(new Font("Century Gothic", Font.BOLD, 18));
SF.setBounds(255, 23, 134, 23);
frame.getContentPane().add(SF);

JLabel lblName = new JLabel("NAME:");


lblName.setFont(new Font("Century Gothic", Font.BOLD, 15));
lblName.setBounds(10, 64, 134, 23);
frame.getContentPane().add(lblName);

Name = new JTextField();


Name.setBounds(68, 64, 365, 20);
frame.getContentPane().add(Name);

JLabel lblAddress = new JLabel("ADDRESS:");


lblAddress.setFont(new Font("Century Gothic", Font.BOLD, 15));
lblAddress.setBounds(10, 88, 134, 23);
frame.getContentPane().add(lblAddress);

Address = new JTextField();


Address.setBounds(88, 91, 345, 20);
frame.getContentPane().add(Address);

JLabel lblStudentId = new JLabel("STUDENT ID:");


lblStudentId.setFont(new Font("Century Gothic", Font.BOLD, 15));
lblStudentId.setBounds(443, 64, 134, 23);
frame.getContentPane().add(lblStudentId);

Samuel F. Camorongan
Faculty, College of Information Technology
StudentID = new JTextField();
StudentID.setBounds(536, 64, 128, 20);
frame.getContentPane().add(StudentID);

JLabel lblAge = new JLabel("AGE:");


lblAge.setFont(new Font("Century Gothic", Font.BOLD, 15));
lblAge.setBounds(443, 88, 134, 23);
frame.getContentPane().add(lblAge);

Age = new JTextField();


Age.setBounds(489, 91, 175, 20);
frame.getContentPane().add(Age);

JLabel lblCourse = new JLabel("Course:");


lblCourse.setFont(new Font("Century Gothic", Font.BOLD, 15));
lblCourse.setBounds(10, 141, 134, 23);
frame.getContentPane().add(lblCourse);

Course = new JComboBox<>(new String[]{"Select a Course", "Bachelor of Science in


Accountancy", "Bachelor of Science in Business Administration", "Bachelor of Science in
Civil Engineering", "Bachelor of Science in Criminology", "Bachelor of Science in
Education", "Bachelor of Science in Information Technology", "Bachelor of Science in
Hospitality Management"});
Course.setMaximumRowCount(15);
Course.setBounds(76, 143, 243, 22);
frame.getContentPane().add(Course);

JLabel lblYearBlock = new JLabel("Year & Block:");


lblYearBlock.setFont(new Font("Century Gothic", Font.BOLD, 15));
lblYearBlock.setBounds(329, 141, 134, 23);
frame.getContentPane().add(lblYearBlock);

YearBlock = new JComboBox<>(new String[]{"Select Year & Block", "1st Year - Block
A", "1st Year - Block B", "1st Year - Block C", "1st Year - Block D", "1st Year - Block
E", "2nd Year - Block A", "2nd Year - Block B", "2nd Year - Block C", "2nd Year - Block
D", "2nd Year - Block E", "3rd Year - Block A", "3rd Year - Block B", "3rd Year - Block
C", "3rd Year - Block D", "3rd Year - Block E", "4th Year - Block A", "4th Year - Block
B", "4th Year - Block C", "4th Year - Block D", "4th Year - Block E"});
YearBlock.setMaximumRowCount(25);
YearBlock.setBounds(434, 143, 230, 22);
frame.getContentPane().add(YearBlock);

Enrolled = new JRadioButton("Enrolled");


Enrolled.setFont(new Font("Century Gothic", Font.BOLD, 13));
Enrolled.setBounds(155, 218, 114, 23);
frame.getContentPane().add(Enrolled);

NotEnrolled = new JRadioButton("Not Enrolled");


NotEnrolled.setFont(new Font("Century Gothic", Font.BOLD, 13));
NotEnrolled.setBounds(155, 244, 114, 23);
frame.getContentPane().add(NotEnrolled);

Female = new JRadioButton("Female");


Female.setFont(new Font("Century Gothic", Font.BOLD, 13));
Female.setBounds(308, 218, 114, 23);
frame.getContentPane().add(Female);

Male = new JRadioButton("Male");


Male.setFont(new Font("Century Gothic", Font.BOLD, 13));
Male.setBounds(308, 244, 114, 23);
frame.getContentPane().add(Male);

JButton Submit = new JButton("SUBMIT");


Submit.setFont(new Font("Century Gothic", Font.BOLD, 14));
Submit.setBounds(114, 296, 97, 32);
frame.getContentPane().add(Submit);
Submit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JOptionPane.showMessageDialog(frame, "Thank you for the response!");
clearFields();

Samuel F. Camorongan
Faculty, College of Information Technology
}
});

JButton Clear = new JButton("CLEAR");


Clear.setFont(new Font("Century Gothic", Font.BOLD, 14));
Clear.setBounds(245, 296, 97, 32);
frame.getContentPane().add(Clear);
Clear.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
clearFields();
}
});

JButton Exit = new JButton("EXIT");


Exit.setFont(new Font("Century Gothic", Font.BOLD, 14));
Exit.setBounds(379, 296, 97, 32);
frame.getContentPane().add(Exit);

lblStatus = new JLabel("Status:");


lblStatus.setFont(new Font("Century Gothic", Font.BOLD, 15));
lblStatus.setBounds(174, 188, 134, 23);
frame.getContentPane().add(lblStatus);

lblGender = new JLabel("Gender:");


lblGender.setFont(new Font("Century Gothic", Font.BOLD, 15));
lblGender.setBounds(327, 188, 134, 23);
frame.getContentPane().add(lblGender);
Exit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
int confirm = JOptionPane.showConfirmDialog(frame, "Are you sure you want
to exit?", "Exit Confirmation", JOptionPane.YES_NO_OPTION);
if (confirm == JOptionPane.YES_OPTION) {
System.exit(0);
}
}
});
}

private void clearFields() {


Name.setText("");
Address.setText("");
StudentID.setText("");
Age.setText("");
Course.setSelectedIndex(0);
YearBlock.setSelectedIndex(0);
Enrolled.setSelected(false);
NotEnrolled.setSelected(false);
Female.setSelected(false);
Male.setSelected(false);
}
}

SIMULATION PER BUTTON:

Samuel F. Camorongan
Faculty, College of Information Technology
Samuel F. Camorongan
Faculty, College of Information Technology

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy