Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.*;
- import java.awt.event.*;
- import javax.swing.*;
- public class Okno extends JFrame{
- private JButton button = new JButton("Test");
- private JTextField field = new JTextField(5);
- private JRadioButton radio1 = new JRadioButton("Male");
- private JRadioButton radio2 = new JRadioButton("Female");
- public Okno(){
- this.setTitle("Hello");
- this.setBounds(800,600,0,0);
- this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- this.setVisible(true);
- Container contain = this.getContentPane();
- contain.setLayout(new GridLayout(3,2,2,2));
- contain.add(field);
- ButtonGroup group = new ButtonGroup();
- group.add(radio1);
- group.add(radio2);
- contain.add(radio1);
- contain.add(radio2);
- radio2.setSelected(true);
- button.addActionListener(new ButtonEventListener());
- contain.add(button);
- }
- class ButtonEventListener implements ActionListener{
- public void actionPerformed(ActionEvent e ) {
- button.setText("Clciked");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment