Here is a Java Program to Demonstrate the Frame in AWT Java.
Output of Above Java Program
import java.awt.*; import java.awt.event.*; class MyFrame extends Frame implements WindowListener, ActionListener{ Button b1,b2,b3,b4,b5; public MyFrame(String title) { super(title); setSize(200,100); setVisible(true); addWindowListener(this); setLayout(new BorderLayout()); b1=new Button("North"); add(b1,BorderLayout.NORTH); b2=new Button("South"); add(b2,BorderLayout.SOUTH); b3=new Button("East"); add(b3,BorderLayout.EAST); b4=new Button("West"); add(b4,BorderLayout.WEST); b5=new Button("Center"); add(b5,BorderLayout.CENTER); b1.addActionListener(this); b2.addActionListener(this); b3.addActionListener(this); } public void windowOpened(WindowEvent we){} public void windowClosing(WindowEvent we){ dispose(); } public void windowClosed(WindowEvent we) {} public void windowActivated(WindowEvent we) {} public void windowDeactivated(WindowEvent we) {} public void windowIconified(WindowEvent we) {} public void windowDeiconified(WindowEvent we){} public void actionPerformed(ActionEvent ae) { if(ae.getSource()==b1) javax.swing.JOptionPane.showMessageDialog(this,"Left"); if(ae.getSource()==b2) javax.swing.JOptionPane.showMessageDialog(this,"Center"); if(ae.getSource()==b3) javax.swing.JOptionPane.showMessageDialog(this,"Right"); } public static void main(String args[]) { MyFrame frm=new MyFrame("My Frame"); } }
Output of Above Java Program