1.1,1.2 AWT Controls
1.1,1.2 AWT Controls
Panel
-subclass of container and it is the super class of Applet.
-It is a window that does not have a title bar menu bar or border.
Methods-
1.Panel()
2. void setSize(int Width, int Height)
3. void setBounds(int x,int y,int width,int height)
Window
-Window is also a Sub Class of a Container and window class creates a top level window.
-These are not directly created
Methods-
1. void pack()
2.void show()
3.void dispose()
Frame
-It is a subclass of Window
-has a title bar, menu bar, borders, and resizing corners.
Methods-
1.frame()
2.frame(string title)
3.void setVisible(boolean true/false)
4.void setSize(int width, int height)
5.void setTitle(String tile)
Canvas
it is not part of the hierarchy for applet or frame windows
1.2 Creating window Program and Applet
-We can create standalone application by using Frame
-we can create webbased application by using Applet
Two way to creating Frame-
1. By creating the object of Frame class
2. By extending Frame class
1. By creating the object of Frame class
import java.awt.*;
public class Framed1
{
public static void main(String args[])
{
/* Creating a frame object */
Frame frmobj=new Frame("My First Frame");
frmobj.setSize(400,450);
frmobj.setVisible(true);
}
}
Note- compile using javac Framed1.java and execute it by java Framed1
import java.applet.Applet;
import java.awt.Graphics;