Sunday, 27 May 2012

Program to exit from a frame in JAVA


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

 class MyFrame extends JFrame  // implements ActionListener
{
JButton btn1;



public MyFrame(String s)
{ super(s);
setLayout(new FlowLayout());
setVisible(true);
// setSize(400,400);
btn1=new JButton("close");
 
add(btn1);

pack();

btn1.addActionListener(new ActionListener(){

public void actionPerformed(ActionEvent ae)
{
 try{
       dispose();  
  }
  catch(Exception e) {}
}});
}
public static void main(String args[])
{
MyFrame ob=new MyFrame("New Frame");

}
}

1 comment:

  1. I have read your blog its very attractive and impressive. I like it your blog.

    Java Online Training Java EE Online Training Java EE Online Training Java 8 online training Core Java 8 online training

    Java Online Training from India Java Online Training from India Core Java Training Online Core Java Training Online Java Training InstitutesJava Training Institutes

    ReplyDelete