AmateurKid

Untitled

Mar 8th, 2019
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. import java.awt.*;
  2. import java.awt.event.*;
  3. import javax.swing.*;
  4.  
  5.  
  6.  
  7.  
  8. public class Okno extends JFrame{
  9.  
  10. private JButton button = new JButton("Test");
  11. private JTextField field = new JTextField(5);
  12. private JRadioButton radio1 = new JRadioButton("Male");
  13. private JRadioButton radio2 = new JRadioButton("Female");
  14.  
  15.  
  16. public Okno(){
  17.  
  18. this.setTitle("Hello");
  19. this.setBounds(800,600,0,0);
  20. this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  21. this.setVisible(true);
  22.  
  23. Container contain = this.getContentPane();
  24. contain.setLayout(new GridLayout(3,2,2,2));
  25. contain.add(field);
  26.  
  27.  
  28. ButtonGroup group = new ButtonGroup();
  29. group.add(radio1);
  30. group.add(radio2);
  31. contain.add(radio1);
  32. contain.add(radio2);
  33. radio2.setSelected(true);
  34.  
  35. button.addActionListener(new ButtonEventListener());
  36. contain.add(button);
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43. }
  44.  
  45. class ButtonEventListener implements ActionListener{
  46. public void actionPerformed(ActionEvent e ) {
  47. button.setText("Clciked");
  48.  
  49. }
  50.  
  51. }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment