Frame With Anonymous class Example

import java.awt.*;
import java.awt.event.*;

/**
 *
 * @author bhavesh
 */

public class MyFrameAnonymous extends Frame {
private Button btexit;
    public MyFrameAnonymous() {
       
        setLayout(new FlowLayout());
        btexit = new Button("Exit");
        add(btexit);
       
        btexit.addActionListener(
               
                new ActionListener()
                {
                    public void actionPerformed(ActionEvent ae)
                    {
                   
                        System.exit(0);
                    }
                }
                );
               
       setVisible(true);
       setSize(400,400);
    }

   
   
    public static void main(String[] args) {
                   
        new MyFrameAnonymous();
    }
}

Comments

Popular posts from this blog

Custom Exception example for BankAccount

HashMap HashSet example

Annotation