CI 2019 von Daniel, Eugen und Michael
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.6 KiB

  1. import java.awt .*;
  2. import javax.swing .*;
  3. import java.awt.event .*;
  4. public class D_Test {
  5. public class NewStudent {
  6. public static void
  7. (String[] args) {
  8. NewStudent st = new NewStudent();
  9. }
  10. public NewStudent() {
  11. JFrame frame = new JFrame("STUDENT REGISTRATION FORM");
  12. frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  13. frame.setSize(800, 600);
  14. frame.setVisible(true);
  15. JPanel p1 = new JPanel();
  16. p1.setLayout(null);
  17. p1.setBackground(Color.CYAN);
  18. frame.add(p1);
  19. ButtonGroup buttonGroup = new ButtonGroup();
  20. JRadioButton male = new JRadioButton("MALE");
  21. male.setBounds(100, 170, 100, 20);
  22. buttonGroup.add(male);
  23. p1.add(male);
  24. JRadioButton female = new JRadioButton("FEMALE");
  25. female.setBounds(250, 170, 100, 20);
  26. buttonGroup.add(female);
  27. p1.add(female);
  28. JLabel sex = new JLabel("SEX:");
  29. sex.setBounds(10, 200, 100, 20);
  30. p1.add(sex);
  31. final JTextField gender = new JTextField();
  32. gender.setBounds(100, 200, 300, 20);
  33. p1.add(gender);
  34. male.addActionListener(new ActionListener() {
  35. public void actionPerformed(ActionEvent ie) {
  36. gender.setText("MALE");
  37. }
  38. });
  39. female.addActionListener(new ActionListener() {
  40. public void actionPerformed(ActionEvent ie) {
  41. gender.setText("FEMALE");
  42. }
  43. });
  44. }
  45. }
  46. }