Showing posts with label Using Grid Layout Manager. Show all posts
Showing posts with label Using Grid Layout Manager. Show all posts

Friday, 12 August 2011

Frame Class Populated with MenuBar,Menu and MenuItem along with TextField

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



class MyFrame extends Frame implements ActionListener{
   
        MyFrame(){
     Frame f = new Frame();
     MenuBar mb =new MenuBar();
                  Menu filem = new Menu("File");
                 Menu filem1 = new Menu("Edit");
                MenuItem mi = new MenuItem("Save");
                 MenuItem m2 = new MenuItem("Exit");
               MenuItem mi1 = new MenuItem("abc");
                    filem.add(mi);
                    filem.add(m2);                 
                    filem1.add(mi1);
                   mb.add(filem);
                   mb.add(filem1);
                   f.setMenuBar(mb);
                      f.setLayout(new GridLayout(2,2));
                Label l=new Label("user");
                 Label l1=new Label("password");
                TextField tf = new TextField(20);
                 TextField tf1 = new TextField(20);
             f.add(l);  
              f.add(tf);
                f.add(l1); 
                  f.add(tf1);
              
                   f.setSize(400,400);

    f.setVisible(true);
    }//end of my fram

public void actionPerformed(ActionEvent ae){}


public static void main(String m[]){
 new MyFrame();
        
    }//end of void

}//end of class