0% found this document useful (0 votes)
9 views11 pages

1.1,1.2 AWT Controls

Uploaded by

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

1.1,1.2 AWT Controls

Uploaded by

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

Chapter 1

Abstract windowing Toolkit(AWT)


Unit Outcome-
1. Develop Graphical user interface(GUI) programs using AWT components for the
given problem
2. Create frame window with the specified AWT controls
3. Arrange the GUI components using specified layout manager
4. Develop a program using menu and Dialog boxes for given problem
1.1. component,container,Panel,window,frame
Component
At the top of the AWT hierarchy is the Component class. Component is an abstract class that
encapsulates all of the attributes of a visual component.
Examples -buttons, checkboxes, and scrollbars
Methods –
1. void setSize(int Width, int Height)
2. void setLocation (int x,int y)
3. void setBounds(int x,int y,int width,int height)
4. void setForeground(Color c)
5. void setBackground(Color c)
Container
-The Container class is a subclass of Component.
- it provides to laying out the component
Methods-
1. void add (Object o)
2 void remove(Object o)
3.void removeAll()

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

Note- You have to do program and see the output


2. By extending Frame class
Program-
import java.awt.*;
class First extends Frame
{
First()
{
setSize(300,400);//frame size 300 width and 400 height
setVisible(true);//now frame will be visible, by default not visible
setTitle("My first Frame");
}
public static void main(String args[])
{
First f=new First();
}
}
Note- compile using javac First.java and execute it by java First

Note- You have to do program and see the output


2. By extending Frame class
Program-
import java.awt.*;
class First extends Frame
{
First()
{
setSize(300,400);//frame size 300 width and 400 height
setVisible(true);//now frame will be visible, by default not visible
setTitle("My first Frame");
}
public static void main(String args[])
{
First f=new First();
}
}
Note- compile using javac First.java and execute it by java First

Note- You have to do program and see the output


Applet

import java.applet.Applet;
import java.awt.Graphics;

// HelloWorld class extends Applet


public class HelloWorld extends Applet
{
// Overriding paint() method
@Override
public void paint(Graphics g)
{
g.drawString(“Welcome in Applets", 20, 20);
}
Note- You have to do program and see the output
}

/* <applet code="HelloWorld" width=200 height=60>


</applet> */

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy