0% found this document useful (0 votes)
8 views2 pages

Java CardLayout Tutorial

AJP Practical No. 4 - 2nd code

Uploaded by

xamexi1077
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views2 pages

Java CardLayout Tutorial

AJP Practical No. 4 - 2nd code

Uploaded by

xamexi1077
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

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:

You might also like