I. Practical Significance:
A layout manager automatically arranges your controls
within a window. While it is possible to lay out Java controls by hand, too,
you generally won’t. It is
very tedious to manually lay out a large
number of components
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 design simple calculator with the use of
GridLayout.
VI.
Relevant Affective domain
related Outcome(s)
1.
Follow precautionary measures.
2. Follow naming conventions.
3. Follow ethical practices.
VII. Minimum Theoretical Background
Layout Manager is a facility that determines how components should be arranged when they are added to the container. Layout Manager is an interface that is implemented by all the classes of layout managers. There are following classes that represent the layout managers.
Understand the default layout for different containers such as Applet, Frame, Panel.
Grid Layout is used to make a bunch of components equal in size and
displays them in the requested number of rows and columns. One component is
displayed in each rectangle.
The list of
Constructor for GridLayout are:
1. GridLayout():
creates a grid layout with one column per component in a row.
2. GridLayout(int rows, int columns): creates a grid layout with the given rows and columns but no gaps between the components.
3. GridLayout(int rows, int columns, int hgap, int vgap): creates a grid layout with the given rows and columns along with given horizontal and vertical gaps if we give setLayout(null) the default layout is disabled.then we have to use setBounds method to layout the components
X. Program
Code: Teacher must assign a separate program statement to group of 3-4 students.
1. Write java
Program to Demonstrate Grid of 5* 5
2. Write a program to display The Number on Button from 0 to 9.
XII.
Practical Related Questions
Note: Below given
are few sample questions for reference. Teacher must design
more such questions so as to ensure the achievement of identified CO.
1. Give name of
default Layout for Different container
2. List the names of
BorderLayout regions.
3. Write the default
horizontal and vertical gap in FlowLayout
4.
Write the use of Insets in border layout.
I.
Exercise
1.
Write a program to generate following output
Figure 3
import java.awt.*;
public class PR3a{
public static void main(String[] args) {
Frame f=new Frame();
Button b1=new Button("Button1");
Button b2=new Button("Button2");
Button b3=new Button("Button3");
Button b4=new Button("Button4");
Button b5=new Button("Button5");
f.add(b1);
f.add(b2);
f.add(b3);
f.add(b4);
f.add(b5);
f.setLayout(new GridLayout(3,2,30,30));
f.setSize(400,250);
f.setVisible(true);
}
}
2. Write a program to generate following output using Border Layout
import java.awt.*;
import javax.swing.*;
public class PR3b {
public static void main(String[] args) {
Frame f=new Frame();
Button b1=new Button("North");
Button b2=new Button("South");
Button b3=new Button("East");
Button b4=new Button("West");
Button b5=new Button("Center");
f.add(b1,BorderLayout.NORTH);
f.add(b2,BorderLayout.SOUTH);
f.add(b3,BorderLayout.EAST);
f.add(b4,BorderLayout.WEST);
f.add(b5,BorderLayout.CENTER);
f.setSize(300,300);
f.setVisible(true); }
}
Comments
Post a Comment