Practical No.
: 04
Practical Name: Use of CardLayout to write a program to create a two-level card deck that allows
the user to select an operating system.
Roll No.: 47
Student Name: Mavani Ashish Shantilal
Program:
 import java.awt.*;
    class practical4_2
    {
           public static void main(String args[])
           {
                   Frame f = new Frame("GridBag Layout");
                   f.setVisible(true);
                   f.setSize(400,300);
                   f.setLayout(new GridBagLayout());
                 GridBagConstraints gcb = new GridBagConstraints();
                 gcb.fill = GridBagConstraints.BOTH;
                 Button b1 = new Button("Button One");
                 gcb.gridx = 0;
                 gcb.gridy = 0;
                 f.add(b1, gcb);
                 Button b2 = new Button("Button two");
                 gcb.gridx = 1;
                 gcb.gridy = 0;
                 f.add(b2, gcb);
                 Button b3 = new Button("Button Three");
                 gcb.gridx = 0;
                 gcb.gridy = 1;
                 f.add(b3, gcb);
                 Button b4 = new Button("Button Four");
                 gcb.gridx = 1;
                 gcb.gridy = 1;
                 f.add(b4, gcb);
                 Button b5 = new Button("Button Five");
                 gcb.gridx = 0;
                 gcb.gridy = 2;
                 f.add(b5, gcb);
          }
}
Output: