mport java.awt.
*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
public class biodata {
public static void main(String[] args) {
JFrame frame = new JFrame("Student Biodata Form");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(400, 300);
frame.setLayout(new GridLayout(8, 2, 10, 10));
JLabel nameLabel = new JLabel("Name:");
JTextField nameField = new JTextField();
frame.add(nameLabel);
frame.add(nameField);
JLabel ageLabel = new JLabel("Age:");
JTextField ageField = new JTextField();
frame.add(ageLabel);
frame.add(ageField);
JLabel genderLabel = new JLabel("Gender:");
JRadioButton maleButton = new JRadioButton("Male");
JRadioButton femaleButton = new JRadioButton("Female");
ButtonGroup genderGroup = new ButtonGroup();
genderGroup.add(maleButton);
genderGroup.add(femaleButton);
JPanel genderPanel = new JPanel();
genderPanel.add(maleButton);
genderPanel.add(femaleButton);
frame.add(genderLabel);
frame.add(genderPanel);
JLabel interestsLabel = new JLabel("Interests:");
JCheckBox readingCheckBox = new JCheckBox("Reading");
JCheckBox sportsCheckBox = new JCheckBox("Sports");
JCheckBox musicCheckBox = new JCheckBox("Music");
JPanel interestsPanel = new JPanel();
interestsPanel.add(readingCheckBox);
interestsPanel.add(sportsCheckBox);
interestsPanel.add(musicCheckBox);
frame.add(interestsLabel);
frame.add(interestsPanel);
JLabel coursesLabel = new JLabel("Courses:");
String[] courses = {"Mathematics", "Science", "History", "Computer
Science"};
JList<String> coursesList = new JList<>(courses);
JScrollPane listScrollPane = new JScrollPane(coursesList);
frame.add(coursesLabel);
frame.add(listScrollPane);
JButton submitButton = new JButton("Submit");
frame.add(new JLabel());
frame.add(submitButton);
submitButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String name = nameField.getText();
String age = ageField.getText();
String gender = maleButton.isSelected() ? "Male" : "Female";
StringBuilder interests = new StringBuilder();
if (readingCheckBox.isSelected()) interests.append("Reading
");
if (sportsCheckBox.isSelected()) interests.append("Sports ");
if (musicCheckBox.isSelected()) interests.append("Music ");
String selectedCourses =
coursesList.getSelectedValuesList().toString();
JOptionPane.showMessageDialog(frame,
"Name: " + name + "\n" +
"Age: " + age + "\n" +
"Gender: " + gender + "\n" +
"Interests: " + interests.toString() + "\n" +
"Selected Courses: " + selectedCourses
);
}
});
frame.setVisible(true);
}
}