Ex.
No: 04 STUDENT INFORMATION SYSTEM
Aim:
To create a student information system using java swing that collects and displays personal and academic
information across multiple tabs.
Algorithm:
Step-1: Create a window with a tabbed pane containing three tabs: one for personal information,
one for academic information, and one for summary details.
Step-2: In the personal information tab, add labeled text fields for first name, last name, and age;
radio buttons for gender selection; and checkboxes for skill selection. Add a "Next" button to navigate
to the academic information tab.
Step-3: In the academic information tab, add labeled text fields for college name and CGPA; dropdown menus
for degree and graduation year; and buttons for navigating back to the personal information tab and
forward to the summary tab.
Step-4: In the summary tab, add a text area to display the input details and a "Submit" button to finalize the
registration. Make the text area non-editable and add a scroll pane for it.
Program:
import [Link].*;
import [Link].*;
import [Link];
import [Link];
public class StudentInformationSystem extends JFrame implements ActionListener {
JTabbedPane tabbedPane;
JPanel personalPanel, academicPanel, finalPanel;
JTextField firstNameField, lastNameField, ageField;
JRadioButton maleButton, femaleButton, otherButton;
JCheckBox javaCheckBox, pythonCheckBox, cppCheckBox;
JComboBox<String> yearComboBox, degreeComboBox;
JTextField collegeNameField, cgpaField;
JButton nextButton1, nextButton2, backButton, submitButton;
JTextArea resultArea;
ButtonGroup genderGroup;
StudentInformationSystem() {
setTitle("Student Information System");
setSize(500, 500);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
tabbedPane = new JTabbedPane();
// Personal Information Panel
personalPanel = new JPanel(new GridLayout(8, 2));
[Link](new JLabel("First Name:"));
firstNameField = new JTextField();
[Link](firstNameField);
[Link](new JLabel("Last Name:"));
lastNameField = new JTextField();
[Link](lastNameField);
[Link](new JLabel("Age:"));
ageField = new JTextField();
[Link](ageField);
[Link](new JLabel("Gender:"));
JPanel genderPanel = new JPanel();
maleButton = new JRadioButton("Male");
femaleButton = new JRadioButton("Female");
otherButton = new JRadioButton("Other");
genderGroup = new ButtonGroup();
[Link](maleButton);
[Link](femaleButton);
[Link](otherButton);
[Link](maleButton);
[Link](femaleButton);
[Link](otherButton);
[Link](genderPanel);
[Link](new JLabel("Skills:"));
JPanel skillsPanel = new JPanel();
javaCheckBox = new JCheckBox("Java");
pythonCheckBox = new JCheckBox("Python");
cppCheckBox = new JCheckBox("C++");
[Link](javaCheckBox);
[Link](pythonCheckBox);
[Link](cppCheckBox);
[Link](skillsPanel);
nextButton1 = new JButton("Next");
[Link](this);
[Link](nextButton1);
[Link]("Personal Information", personalPanel);
// Academic Information Panel
academicPanel = new JPanel(new GridLayout(6, 2));
[Link](new JLabel("College Name:"));
collegeNameField = new JTextField();
[Link](collegeNameField);
[Link](new JLabel("Degree:"));
String[] degrees = {"BSc", "BA", "BCom", "BEng", "BTech", "MSc", "MA", "MCA", "MEng",
"MTech"};
degreeComboBox = new JComboBox<>(degrees);
[Link](degreeComboBox);
[Link](new JLabel("Graduation Year:"));
String[] years = {"2019","2020","2021","2022","2023","2024"};
yearComboBox = new JComboBox<>(years);
[Link](yearComboBox);
[Link](new JLabel("CGPA:"));
cgpaField = new JTextField();
[Link](cgpaField);
backButton = new JButton("Back");
[Link](this);
[Link](backButton);
nextButton2 = new JButton("Next");
[Link](this);
[Link](nextButton2);
[Link]("Academic Information", academicPanel);
// Final Panel to display details
finalPanel = new JPanel(new BorderLayout());
resultArea = new JTextArea();
[Link](false);
[Link](new JScrollPane(resultArea), [Link]);
submitButton = new JButton("Submit");
[Link](this);
[Link](submitButton, [Link]);
[Link]("Summary", finalPanel);
add(tabbedPane);
setVisible(true);
}
public void actionPerformed(ActionEvent e) {
if ([Link]() == nextButton1) {
[Link](1);
} else if ([Link]() == backButton) {
[Link](0);
} else if ([Link]() == nextButton2) {
[Link](2);
displayDetails();
} else if ([Link]() == submitButton) {
displayDetails();
[Link](this, "Registration Successful!");
}
}
private void displayDetails() {
StringBuilder personalInfo = new StringBuilder();
[Link]("Personal Information:\n")
.append("First Name: ").append([Link]()).append("\n")
.append("Last Name: ").append([Link]()).append("\n")
.append("Age: ").append([Link]()).append("\n")
.append("Gender: ");
if ([Link]()) {
[Link]("Male\n");
} else if ([Link]()) {
[Link]("Female\n");
} else if ([Link]()) {
[Link]("Other\n");
} else {
[Link]("Not specified\n"); }
[Link]("Skills: ");
if ([Link]()) {
[Link]("Java "); }
if ([Link]()) {
[Link]("Python "); }
if ([Link]()) {
[Link]("C++ ");}
[Link]("\n");
StringBuilder academicInfo = new StringBuilder();
[Link]("Academic Information:\n")
.append("College Name: ").append([Link]()).append("\n")
.append("Degree: ").append([Link]().toString()).append("\n")
.append("Graduation Year: ").append([Link]().toString()).append("\n")
.append("CGPA: ").append([Link]()).append("\n");
[Link]([Link]() + [Link]());
}
public static void main(String[] args) {
new StudentInformationSystem();
}
}
Output:
Personal Information Tab
Academic Information Tab
Summary Tab
Result:
Thus, the student information system using java swing that collects and displays personal and
academic information across multiple tabs was executed successfully and the output was verified.