Seach

simple jframe with jbutton and associated event


package jframe;
import java.awt.event.*;
import javax.swing.*;

public class Jframe extends JFrame implements ActionListener
{
JFrame jf;
JButton jb;
JRadioButton jr1,jr2;
    public Jframe()
    {
       setLayout(null);
       jb=new JButton();
       jb.setText("click me");
       jb.setBounds(20, 40, 100, 100);
      // add(jb);
     
       jb.addActionListener(this);
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        System.out.println("event generated");
    }

   
    public static void main(String[] args)
    {
      Jframe j=new Jframe();
       j.setSize(400, 400);
       j.setVisible(true);
    }
}

No comments: