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

Practical No. 4: Use of Cardlayout To Write A Program To Create A Two-Level Card Deck That Allows The User To Select An Operating System

1) The document describes a practical for using CardLayout to create a two-level card deck that allows a user to select an operating system. 2) CardLayout treats each component as a card and only allows one component to be visible at a time. 3) The practical aims to develop skills in using different layout managers and the AWT/Swing GUI framework to demonstrate CardLayout.

Uploaded by

Om Kawate
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)
76 views2 pages

Practical No. 4: Use of Cardlayout To Write A Program To Create A Two-Level Card Deck That Allows The User To Select An Operating System

1) The document describes a practical for using CardLayout to create a two-level card deck that allows a user to select an operating system. 2) CardLayout treats each component as a card and only allows one component to be visible at a time. 3) The practical aims to develop skills in using different layout managers and the AWT/Swing GUI framework to demonstrate CardLayout.

Uploaded by

Om Kawate
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

Advanced Java Programming (22517)

Practical No. 4: Use of CardLayout to write a program to create a


two-level card deck that allows the user to select an
operating system.
I. Practical Significance:
The CardLayout class manages the components in such a manner that only one
component is visible at a time. It treats each component as a card hence known as
CardLayout.

II. Relevant Program Outcomes (POs)


 Basic knowledge: Apply knowledge of basic mathematics, sciences and basic
engineering to solve the computer group related problems.
 Discipline knowledge: Apply Computer Programming knowledge to solve the
computer group related problems.
 Experiments and practice: Plan to perform experiments and practices to use the
results to solve the computer group related problems.
 Engineering tools: Apply relevant Computer programming / technologies and
tools with an understanding of the limitations.
 Individual and Team work: Function effectively as a leader and team member in
diverse/multidisciplinary teams.
 Communication: Communicate effectively in oral and written form.

III. Competency and Practical skills


To develop standalone applications
The practical is expected to develop the following skills:
1. Able to apply different layouts to Applet, Frame and Panel
2. Able to demonstrate the use of different types of Layout Manager

IV. Relevant Course Outcome(s)


Develop programs using GUI Framework (AWT and Swing).

V. Practical Outcome (PrOs)


Write a program to demonstrate the use of Border layout showing four buttons at four
sides of an applet with captions “left”, “right”, “top” and “bottom”

VI. Relevant Affective domain related Outcome(s)


1. Follow precautionary measures.
2. Follow naming conventions.
3. Follow ethical practices.

VII. Minimum Theoretical Background


Constructors of CardLayout class
1. CardLayout(): creates a card layout with zero horizontal and vertical gap.
2. CardLayout(int hgap, int vgap): creates a card layout with the given horizontal
and vertical gap.

Commonly used methods of CardLayout class


1. public void next (Container parent): is used to flip to the next card of the given
container.

Maharashtra state Board of Technical Education 19


Advanced Java Programming (22517)

2. public void previous (Container parent): is used to flip to the previous card of
the given container.
3. public void first (Container parent): is used to flip to the first card of the given
container.
4. public void last (Container parent): is used to flip to the last card of the given
container.
5. public void show (Container parent, String name): is used to flip to the
specified card with the given name.

VIII. Resources required (Additional)–

Nil

IX. Resources used (Additional)

Sr. Name of
Broad Specification Quantity Remarks (If any)
No. Resource
1

X. Program Code: Teacher must assign a separate program statement to group of


3-4 students.
Execute the following Program and write the output.

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class CardLayoutExample extends JFrame implements ActionListener


{
CardLayout card;
JButton b1, b2, b3;
Container c;
CardLayoutExample()
{
c=getContentPane();
card=new CardLayout(40,30);
//create CardLayout object with 40 hor space and 30 ver space
c.setLayout(card);
b1=new JButton("Apple");
b2=new JButton("Boy");
b3=new JButton("Cat");
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
c.add("a",b1);c.add("b",b2);c.add("c",b3);
}

Maharashtra state Board of Technical Education 20

You might also like