Give name of
Layout for Different Container
Ans:
Default
layout of frame and windows is BorderLayout
And D0efault
layout of panel and applet is FlowLayout
List the names of
Border Layout regions
Ans:
i.East
ii.West
iii.South
iv.North
v.Center
Write the default
horizontal and vertical gap in FlowLayout
Ans:
5Unit
Write the use of Insets in border layout
Ans:
If you want to leave a small space between the container that holds your
components and the window that contains it. To do this, override the getInsets() method that is defined by the
container.
Insets(int top, int left, int bottom, int right)
The values passed in top, left, bottom and right specify the
amount of space between the container and its enclosing window.
Write a program using Borderlayout regions
import
java.awt.*;
import
java.awt.event.*;
public
class Region
{
Region()
{
Frame f=new
Frame();
Button b1=new
Button("East");
Button b2=new
Button("West");
Button b3=new
Button("South");
Button b4=new
Button("North");
Button b5=new
Button("Center");
f.add(b1,BorderLayout.EAST);
f.add(b2,BorderLayout.WEST);
f.add(b3,BorderLayout.SOUTH);
f.add(b4,BorderLayout.NORTH);
f.add(b5,BorderLayout.CENTER);
f.setSize(300,300);
f.setVisible(true);
}
public static void main(String[] args) {
new
Region();
}
}
Write a program to display the number on button from 0
to 9
import
java.awt.*;
import
java.awt.event.*;
public
class Grid
{
Grid()
{
Frame
f=new Frame();
Button b1=new
Button("1");
Button b2=new
Button("2");
Button b3=new
Button("3");
Button b4=new
Button("4");
Button b5=new
Button("5");
Button b6=new
Button("6");
Button b7=new
Button("7");
Button b8=new
Button("8");
Button b9=new
Button("9");
f.add(b1);
f.add(b2);
f.add(b3);
f.add(b4);
f.add(b5);
f.add(b6);
f.add(b7);
f.add(b8);
f.add(b9);
f.setLayout(new
GridLayout(3,3));
f.setSize(500,500);
f.setVisible(true);
}
public
static void main(String[] args) {
new Grid();
}
}
Thanks ππΏππΏππΏππΏππΏπππ
ReplyDeleteThanks
ReplyDelete