recent

Java Program to create a frame Window Using Frame Class

Write a Java Program to create a frame Window Using Frame Class:-

public class AWT1
{
public static void main(String args[])
{
MyFrame mf = new MyFrame();
}
}
import java.awt.event.*;
/*
class MyWindowListener implements WindowListener
{
public void windowActivated(WindowEvent we){}
public void windowDeactivated(WindowEvent we){}
public void windowOpened(WindowEvent we){}
public void windowClosed(WindowEvent we){}
public void windowIconified(WindowEvent we){}
public void windowDeiconified(WindowEvent we){}
public void windowClosing(WindowEvent we)
{
System.exit(0);
}
}
*/
class MyWindowAdapter extends WindowAdapter
{
public void windowClosing(WindowEvent we)
{
System.exit(0);
}
}
import java.awt.*;
import java.awt.event.*;
class MyFrame extends Frame //implements WindowListener
{
MyFrame()
{
super("Sample Java Frame");
//MyWindowListener mwl = new MyWindowListener();
//MyWindowAdapter mwa = new MyWindowAdapter();
//addWindowListener(mwa);
addWindowListener(new MyWindowAdapter());
//addWindowListener(this);
setSize(400,300);
setResizable(true);
//setUndecorated(true);
setVisible(true);
}
}
Powered by Blogger.