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.

53 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 main(String[] args) {
  7. NewStudent st = new NewStudent();
  8. }
  9. public NewStudent() {
  10. JFrame frame = new JFrame("STUDENT REGISTRATION FORM");
  11. frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  12. frame.setSize(800, 600);
  13. frame.setVisible(true);
  14. JPanel p1 = new JPanel();
  15. p1.setLayout(null);
  16. p1.setBackground(Color.CYAN);
  17. frame.add(p1);
  18. ButtonGroup buttonGroup = new ButtonGroup();
  19. JRadioButton male = new JRadioButton("MALE");
  20. male.setBounds(100, 170, 100, 20);
  21. buttonGroup.add(male);
  22. p1.add(male);
  23. JRadioButton female = new JRadioButton("FEMALE");
  24. female.setBounds(250, 170, 100, 20);
  25. buttonGroup.add(female);
  26. p1.add(female);
  27. JLabel sex = new JLabel("SEX:");
  28. sex.setBounds(10, 200, 100, 20);
  29. p1.add(sex);
  30. final JTextField gender = new JTextField();
  31. gender.setBounds(100, 200, 300, 20);
  32. p1.add(gender);
  33. male.addActionListener(new ActionListener() {
  34. public void actionPerformed(ActionEvent ie) {
  35. gender.setText("MALE");
  36. }
  37. });
  38. female.addActionListener(new ActionListener() {
  39. public void actionPerformed(ActionEvent ie) {
  40. gender.setText("FEMALE");
  41. }
  42. });
  43. }
  44. }
  45. }