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.

49 lines
1.6 KiB

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