import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class EventDemo1 extends JFrame {
JButton jbtnExit = new JButton("Exit");
EventDemo1()
{
setTitle("Event Demo 1");
addWindowListener(new WindowAdapter(){
public void windowClosed(WindowEvent e)
{
System.exit(0);
}
});
jbtnExit.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
System.exit(0);
}
});
getContentPane().add(jbtnExit,BorderLayout.SOUTH);
setSize(300,300);
show();
}
JButton jbtnButton = new JButton("Exit");
public static void main(String[] args) {
new EventDemo1();
}
}
import java.awt.event.*;
import javax.swing.*;
public class EventDemo1 extends JFrame {
JButton jbtnExit = new JButton("Exit");
EventDemo1()
{
setTitle("Event Demo 1");
addWindowListener(new WindowAdapter(){
public void windowClosed(WindowEvent e)
{
System.exit(0);
}
});
jbtnExit.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
System.exit(0);
}
});
getContentPane().add(jbtnExit,BorderLayout.SOUTH);
setSize(300,300);
show();
}
JButton jbtnButton = new JButton("Exit");
public static void main(String[] args) {
new EventDemo1();
}
}