Unit 1 (KCS602)
Unit 1 (KCS602)
Unit- I
Introduction and Web Development Strategies
To understand this term in a better manner, let’s break it down into two pieces: ‘web’ and
‘technology’.
The web, in this case, refers to the World Wide Web, more commonly known as WWW.
It first came into being in 1989 when famous scientist and engineer, Tim Berners-Lee,
came up with an efficient mechanism to share resources between scientists all over the
world.
Web Technology
You probably know that computers don't communicate with each other the way that people do.
Instead, computers require codes, or directions. These binary codes and commands allow
computers to process needed information. Every second, billions upon billions of ones and zeros
are processed in order to provide you with the information you need.
So what does that have to do with your ability to post your latest pictures online? Everything.
The methods by which computers communicate with each other through the use of markup
languages and multimedia packages is known as web technology. In the past few decades, web
technology has undergone a dramatic transition, from a few marked up web pages to the ability
to do very specific work on a network without interruption. Let's look at some examples of web
technology.
History of WWW:
In 1990, the first text only browsers were setup and CERN scientistcould
access hypertext files and other information at CERN. HTML was based
on a subset of the standard generalized markup language (SGML). To
transfer HTML document to remote sites a new protocol was devised
called HTTP (Hyper Text Transfer Protocol).
In the fall of 1991, conference goes around the world started hearing about
the promise but sparks still were not flying.
In 1993, there are only about 50 websites world wide. A browser that
allowed user to take advantage of the web’s graphical capabilities was
developed at the National center for Super Computing
application(NCSA). NCSA called the browser Mosaic.
In its infancy stage the Internet was originally conceived by the Department of Defense as a way to protect
government communication systems in the event of military strike. The original network dubbed ARPANet (for the
Advanced Research Projects Agency that developed it) evolved in to a communication channel among contractors,
military personnel and university researchers who were contributing to ARPA projects.
The network employed a set of standard protocols to create an effective way for these people to communicate and
share data with each other. ARPAnet’s popularity continued to spread among researchers and in 1980 the National
Science Foundation linked several high speed computers and took charge of what came known to be as the Internet.
By the late 1980’s thousands of cooperating networks were participating in the Internet. The NREN (National
Research Education Network) took up the initiative to develop and maintain high speed networks for research and
education and to investigate the commercial uses of the Internet.
a. HTTP
b. TCP/IP
c. FTP
d. E-MAIL
e. TELNET
A. HTTP: HTTP is the primary protocol used to distribute information on the web.
Initial HTTP 0.9 does not allow for content typing and does not have provisions for
supplying meta-information.
Content Typing: To identify the type of data being transferred.
B. TCP/IP: It is a set of rules that an application can use to package its information for
sending across the networks of networks.
C. FTP: It is used to transfer the files over networks.
A. Corporate Website:
i. In this, there is certain no. of persons, who develop their website for a
particular organization.
ii. The corporate website are formed when group of people have common
interest and objective.
iii. The purpose of this website is to convey the information of organization to all
over the world.
B. Individual website: It is just like profile management system. In this type of
website an individual wants to develop website for h-projection, career growth etc.
4. Cyber Laws: Cyber law is a term used to describe the legal issues related to use of
communication technology, particularly “cyberspace” i.e. Internet.
Indian and International Cyber Law: Cyber Laws are formed by the government top
revent the internet crime. These crimes could be hacking, threat on internet, denial of
services etc. Cyberspace includes computer, computer networks, internet data,
software etc.
i. Data Protection and Privacy Law: This is due to the nature of the internet and
amount of information that may be accessed through it, such legislation is critical
to protect the fundamental rights of privacy of an individual.
ii. Electronic and Digital Signature Law: This is required so that uniform and
standard procedures are established for authentication of electronics records,
EDI, E-Mail.
iii. Computer Crime Law: due to victim of internet threats.
iv. Telecommunication Law: Approve and supervise the application of fees and
rates charged for telecommunication services in accordance with the provision of
the applicable law.
v. Intellectual Property Law: This includes copyright law, trademark law,
semiconductor law and patent law in relation to computer hardware and
software.
E-Governance
Authentication of E-Records
Digital Signatures
Controlled certifying authorities
Penalties for damage of computer and computer system.
5. Web Applications:
Simple office software (word processors, online spreadsheets, and presentation
tools).
More advanced applications such as project management, computer-aided design,
video editing and point-of-sale.
C. Identify your target users: The matter of a website will be determined by the
users whom you want to visit the site. This is totally depend upon
i. Market research
ii. Focus group
iii. Understanding intranet audiences
D. Determine the scope: By supporting documents and client’s approval.
E. Budget:
i. Assumption for budgets.
ii. Budget categories.
iii. Determine hidden costs and tools.
F. Planning issues:
i. Discuss client’s existing information system.
ii. Project team and developing infrastructure.
iii. Where the websitewill place.
7. Comparison between traditional project and web project:
8. Identification of objects:
A. Object identification: All the components which are visible in website areobjects
or in other words, we can say that all visible components in the web browser are
defined as objects. Ex. Text box, command button etc.
B. Web development process:
Goals and
objectives Team
building Research
and review Project
proposal
Developing concept
Content planning
Rough design
Final design
Build prototype
Prototype testing
Original design
Satisfy the clients
need
Testing and maintenance:
Launch:
Types:
A. Server Side: hired by a company to develop a website.
B. Client Side: part of the company putting together the website.
ofteams and determine to be based on the kind of project, who is likely to be part
of the team though these are all type of web project. As for example the team
etc.
c. Putting together with right team: It meet out the needs with low price,
requirements successfully.
d. Identifying Necessary Skills: The skill set in the base of web team. It must
B. Content planning:
i. Get images.
ii. Create links.
iii. Audio & Video
iv. Shockwave & other media files.
C. Technical planning:
i. Database.
ii. Shockwave movies.
iii. Transaction system.
iv. Scripts of all kinds.
D. Production planning:
i. Market research.
ii. Combine the web pages
iii. Get complete web.
A. ARPANET:
In 1969, a project was funded by the Advanced Research Project
Agency (ARPA), an arm of the U.S. Department of Defense. ARPA
established a packet-switching network of computers linked by
point-to-point leased lines called Advanced Research Project
agency Network (ARPANET) that provided a basis for early
research into networking.
B. ISP:
The Internet Service Provider (ISP) gives you the telephone access and
software you need to connect to the internet along with some technical
help.
Many ISPs also include an electronic mail account, host customers web
pages and offer services a company that do business on the Internet.
There are aprox. 200 ISPs in India like VSNL, MTNL,
ERNET(Education and Research Community Network) etc.
C. UDP:
The User Datagram Protocol (UDP) is one of the core members of the Internet
Protocol Suite, the set of network protocols used for the Internet. With UDP,
computer applications can send messages, in this case referred to as datagrams, to
other hosts on an Internet Protocol (IP) network without requiring prior
communications to set up special transmission channels or data paths.
Packet structure:
bits 0 – 15 16 – 31
32 Length Checksum
64 Data
D. Uploading of files:
E. Portal:
A web portal, also known as a links page, presents information from diverse
sources in a unified way. Apart from the standard search engine feature, web
portals offer other services such as e-mail, news, stock prices, information,
databases and entertainment. Portals provide a way for enterprises to provide a
consistent look and feel with access control and procedures for multiple
applications and databases, which otherwise would have been different entities
altogether. Examples of public web portals are AOL, iGoogle, MSNBC, Netvibes,
and Yahoo.
Internet Services:
Internet is a very good medium to connect with the outer world. People use it as a medium to connect with other
people sharing files, entertainment and lots of other activities that are useful and beneficial in many ways. The few
dominant reasons why people use the Internet are given below:
Information: People browse Internet for information. They love to browse various search engines like Google,
Yahoo to know about any necessary news. Also they love to browse websites like Wikipedia which is a full fledged
encyclopedia on Internet.
Social Networking: Social networking is a good medium to communicate with friends and family members. There
are many social networking sites like Face book, Twitter etc which are used by people in connecting with friends.
Communication: Communication is another way to use the Internet. People connect with others through various IM
services like GTalk, Skype and Yahoo messenger. There are lots of other services through which people send
messages.
Transfer of Files: People – school students, college students, office staff, businesspeople, everyone sends files through
the Internet. This is an essential part of their lives. These files are sent through the Internet. People use various mail
services like Gmail, Yahoo mail, Hotmail etc to send files.
Current News: It is either latest news, or Sport updates; people love to surf Internet to get live update of any news.
Websites like Rediff, NY times are quick news providing websites.
Entertainment: Internet and Entertainment are closely related. It could be in the form of watching videos in
YouTube, plying live games, or downloading movies, Internet provides its entertainment dominance everywhere.
Internet transactions: Now Internet can save time and money of the people. The facility is known as Internet
banking facility through which people can deposit any bill, transfer money through account, and also make Internet
reservation on time from their home.
Marketing: Internet marketers make extensive use of Internet to sell products. There are lots of social media
enthusiasts who promote others’ products online via various social media sites.
Online Education: This has developed very fast in most countries. Various websites offer online courses to learn
various things like designing, programs or subjects. Online education is very helpful to promote education in places
where the courses are not available easily. It also helps in spaced and paced learning.
Internet is a worldwide collection of networks. The Internet has different tools and services that are provided:
E-mail
Voice mail
FTP
WWW
E-Commerce
Chat
Search Engine
Electronic mail (email): E-mail is an electronic mail. The messages can be sent electronically over a network. For
sending or receiving an email, the user must have an email address; email address is given as:
username@location
CLIENT/SERVER COMPUTING:-
According to MIS terminology, Client/Server computing is new technology that yields solutions to many data
management problems faced by modern organizations. The term Client/Server is used to describe a computing model
for the development of computerized systems. This model is based on distribution of functions between two types of
independent and autonomous processes: Server and Client. A Client is any process that requests specific services from
the server process. A Server is a process that provides requested services for the Client. Client and Server processes
can reside in same computer or in different computers linked by a network. When Client and Server processes reside
on two or more independent computers on a network, the Server can provide services for more than one Client. In
addition, a client can request services from several servers on the network without regard to the location or the
physical characteristics of the computer in which the Server process resides. The network ties the server and client
together, providing the medium through which the clients and the server communicate. The Fig. 1.1 given below
shows a basic Client/Server computing model.
From the Fig. 1.1 it is clear that services can be provided by variety of computers in the network. The key point
to Client/Server power is where the request processing takes place. For example: Client/Server Database. In case of
Client/Server database system, the functionality is split between the server system and multiple clients such that
networking of computers allows some tasks to be executed on the client system.
1. File Server
All the files reside on the server machine. File Server provides clients access to records within files from
the server machine. File Servers are useful for sharing files across a network among the different client
process requesting the services. The server process is somewhat primitive because of tends to demand
many message exchanges over the network to find the requested data.
2. Print Server
This machine manages user access to the shared output devices, such as printers. These are the earliest
type of servers. Print services can run on a file server or on one or more separate print server machines.
3. Application Server
This machine manages access to centralized application software; for example, a shared database. When
the user requests information from the database, the application server processes the request and returns
the result of the process to the user.
4. Mail Server
This machine manages the flow of electronic mail, messaging, and communication with mainframe
systems on large-scale networks.
5. Fax Server
Provides the facility to send and receive the Faxes through a single network connection. The Fax server
can be a workstation with an installed FAX board and special software or a specialized device dedicated
and designed for Fax Services. This machine manages flow of fax information to and from the network. It
is similar to the mail server.
6. Directory Services Server
It is found on large-scale systems with data that is distributed throughout multiple servers. This machine
functions as an organization manager, keeping track of what is stored where, enabling fast and reliable
access to data in various locations.
7. Web Server
This machine stores and retrieves Internet (and intranet) data for the enterprise. Some documents, data,
etc., reside on web servers. Web application provides access to documents and other data. “Thin” clients
typically use a web browser to request those documents. Such servers shares documents across intranets,
or across the Internet (or extranets). The most commonly used protocol is HTTP (Hyper Text Transfer
Protocol). Web application servers are now augmenting simple web servers. The examples of web
application servers are Microsoft’s Internet Information Server (IIS), Netscape’s iPlanet IBM’s
WebSphere, BEA’s WebLogic and Oracle Application Server.
8. Database Server
Data resides on server, in the form of a SQL database. Database server provides access to data to clients,
in response to SQL requests. It shares the data residing in a database across a network. Database Server
has more efficient protocol than File Server. The Database Server receives SQL requests and processes
them and returning only the requested data; therefore the client doesn’t have to deal with irrelevant data.
However, the client does have to implement SQL application code. The example of database server is:
Oracle9i database server.
9. Transaction Servers
The data and remote procedures reside on the server. The Server provides access to highlevel functions,
and implements efficient transaction processing. It shares data and highlevel functions across a network.
Transaction servers are often used to implement Online Transaction Processing (OLTP) in high-
performance applications. A transaction server utilizes a more efficient protocol in comparison to a
Database Server. The transaction Server receives high-level function request from the clients and it
implements that function. Often it needs to return less information to the client than a Database Server.
Examples of the Transaction servers mainly categorized as • TP-Light with Database Stored Procedures
like Oracle, Microsoft SQL Server etc. • TP-Heavy with TP Monitors like BEA Tuxedo, IBM CICS/TX
Seri
Core Java
Features of Java
The primary objective of Java programming language creation was to make it portable, simple
and secure programming language. Apart from this, there are also some excellent features which
play an important role in the popularity of this language. The features of Java are also known as
java buzzwords.
1. Simple
2. Object-Oriented
3. Portable
4. Platform independent
5. Secured
6. Robust
7. Architecture neutral
8. Interpreted
9. High Performance
10. Multithreaded
11. Distributed
12. Dynamic
Operators in java
Operator in java is a symbol that is used to perform operations. For example: +, -, *, / etc.
There are many types of operators in java which are given below:
o Unary Operator,
o Arithmetic Operator,
o Shift Operator,
o Relational Operator,
o Bitwise Operator,
o Logical Operator,
o Ternary Operator and
o Assignment Operator.
Java Operator Precedence
additive +-
equality == !=
bitwise exclusive OR ^
bitwise inclusive OR |
logical OR ||
Ternary ternary ?:
Assignment assignment = += -= *= /= %= &= ^= |= <<= >>=
>>>=
1. Primitive data types: The primitive data types include boolean, char, byte, short,
int, long, float and double.
2. Non-primitive data types: The non-primitive data types include
Classes, Interfaces, and Arrays.
In Java language, primitive data types are the building blocks of data
manipulation. These are the most basic data types available in Java
language.
Java Variables
A variable is a container which holds the value while the java program is
executed. A variable is assigned with a datatype.
There are two types of data types in java: primitive and non-primitive.
1) Local Variable
A variable declared inside the body of the method is called local variable.
You can use this variable only within that method and the other methods
in the class aren't even aware that the variable exists.
2) Instance Variable
A variable declared inside the class but outside the body of the method,
is called instance variable. It is not declared as static.
It is called instance variable because its value is instance specific and is
not shared among instances.
3) Static variable
Java Array
Array in java is index-based, the first element of the array is stored at the 0 index.
Java Methods
The method in Java or Methods of Java is a collection of statements that perform some specific task and return the
result to the caller. A Java method can perform some specific task without returning anything. Java Methods allow us
to reuse the code without retyping the code. In Java, every method must be part of some class that is different from
languages like C, C++, and Python.
1. A method is like a function i.e. used to expose the behavior of an object.
2. It is a set of codes that perform a particular task.
Syntax of Method
<access_modifier> <return_type> <method_name>( list_of_parameters)
{
//body
}
Advantage of Method
Code Reusability
Code Optimization
Method Declaration
Java Class
A class is a blueprint for the object. Before we create an object, we first need to define the class.
We can think of the class as a sketch (prototype) of a house. It contains all the details about the
floors, doors, windows, etc. Based on these descriptions we build the house. House is the object.
Since many houses can be made from the same description, we can create many objects
from a class.
Create a class in Java
We can create a class in Java using the class keyword. For example,
class ClassName {
// fields
// methods
}
Here, fields (variables) and methods represent the state and behavior of the object respectively.
fields are used to store data
methods are used to perform some operations
For our bicycle object, we can create the class as
class Bicycle {
// state or field
private int gear = 5;
// behavior or method
public void braking() {
System.out.println("Working of Braking");
}
}
In the above example, we have created a class named Bicycle . It contains a field named gear and
a method named braking() .
Here, Bicycle is a prototype. Now, we can create any number of bicycles using the prototype. And,
all the bicycles will share the fields and methods of the prototype.
Note: We have used keywords private and public . These are known as access modifiers. To learn
more, visit Java access modifiers.
Java Objects
An object is called an instance of a class. For example, suppose Bicycle is a class
then MountainBicycle , SportsBicycle , TouringBicycle , etc can be considered as objects of the class.
Creating an Object in Java
We have used the new keyword along with the constructor of the class to create an object.
Constructors are similar to methods and have the same name as the class. For
example, Bicycle() is the constructor of the Bicycle class. To learn more, visit Java Constructors.
Here, sportsBicycle and touringBicycle are the names of objects. We can use them to access fields
and methods of the class.
As you can see, we have created two objects of the class. We can create multiple objects of a
single class in Java.
Note: Fields and methods of a class are also called members of the class.
We can use the name of objects along with the . operator to access members of a class. For
example,
class Bicycle {
// field of class
int gear = 5;
// method of class
void braking() {
...
}
}
// create object
Bicycle sportsBicycle = new Bicycle();
In the above example, we have created a class named Bicycle . It includes a field named gear and a
method named braking() . Notice the statement,
Here, we have created an object of Bicycle named sportsBicycle . We then use the object to access
the field and method of the class.
sportsBicycle.gear - access the field gear
We have mentioned the word method quite a few times. You will learn about Java methods in
detail in the next chapter.
Inheritance in Java
Inheritance in Java is a mechanism in which one object acquires all the properties and behaviors
of a parent object. It is an important part of OOPs (Object Oriented programming system).
The idea behind inheritance in Java is that you can create new classes that are built upon existing
classes. When you inherit from an existing class, you can reuse methods and fields of the parent
class. Moreover, you can add new methods and fields in your current class also.
Inheritance represents the IS-A relationship which is also known as a parent-child relationship.
Important Terminologies Used in Java Inheritance
Class: Class is a set of objects which shares common characteristics/ behavior and common properties/ attributes.
Class is not a real-world entity. It is just a template or blueprint or prototype from which objects are created.
Super Class/Parent Class: The class whose features are inherited is known as a superclass(or a base class or a
parent class).
Sub Class/Child Class: The class that inherits the other class is known as a subclass(or a derived class, extended
class, or child class). The subclass can add its own fields and methods in addition to the superclass fields and
methods.
Reusability: Inheritance supports the concept of “reusability”, i.e. when we want to create a new class and there is
already a class that includes some of the code that we want, we can derive our new class from the existing class. By
doing this, we are reusing the fields and methods of the existing class.
Example:
class Employee{
float salary=40000;
}
class Programmer extends Employee{
int bonus=10000;
public static void main(String
args[]){ Programmer p=new
Programmer();
System.out.println("Programmer salary is:"+p.salary);
System.out.println("Bonus of Programmer
is:"+p.bonus);
}
}
JAVA Package
A java package is a group of similar types of classes, interfaces and sub-packages.
Package in java can be categorized in two form, built-in package and user-defined
package. There are many built-in packages such as java, lang, awt, javax, swing, net, io,
util, sql etc. Here, we will have the detailed learning of creating and using user-defined
packages.
1) Java package is used to categorize the classes and interfaces so that they can
be easily maintained.
//save as
Simple.java
package
mypack;
public class
Simple{
public static void main(String args[]){
System.out.println("Welcome to
package");
}
}
Interface in Java
An interface in java is a blueprint of a class. It has static constants and abstract methods.
The interface in Java is a mechanism to achieve abstraction. There can be only abstract
methods in the Java interface, not method body. It is used to achieve abstraction and
multiple inheritance in Java.
In other words, you can say that interfaces can have abstract methods and variables. It
cannot have a method body.
interface.
Why use Java interface?
There are mainly three reasons to use interface. They are given below.
Syntax:
interface <interface_name>{
In this example, the Printable interface has only one method, and its implementation is provided
in the A6 class.
interface printable{
void print();
}
class A6 implements printable{
public void print(){System.out.println("Hello");}
In this page, we will learn about Java exceptions, its type and the difference between checked
and unchecked exceptions.
The core advantage of exception handling is to maintain the normal flow of the application.
An exception normally disrupts the normal flow of the application that is why we use exception
handling.
Keyword Description
try The "try" keyword is used to specify a block where we should place
exception code. The try block must be followed by either catch or
finally. It means, we can't use try block alone.
catch The "catch" block is used to handle the exception. It must be
preceded by try block which means we can't use catch block alone. It
can be
followed by finally block later.
finally The "finally" block is used to execute the important code of the
program. It is executed whether an exception is handled or not.
throw The "throw" keyword is used to throw an exception.
throws The "throws" keyword is used to declare exceptions. It doesn't throw an
exception. It specifies that there may occur an exception in the method.
It is always used with method signature.
Multithreading in Java
Multithreading in java is a process of executing multiple threads simultaneously.
However, we use multithreading than multiprocessing because threads use a shared memory
area. They don't allocate separate memory area so saves memory, and context-switching between
the threads takes less time than process.
1) It doesn't block the user because threads are independent and you can perform
multiple operations at the same time.
A thread can be in one of the five states. According to sun, there is only 4 states in thread life
cycle in java new, runnable, non-runnable and terminated. There is no running state.
But for better understanding the threads, we are explaining it in the 5 states.
The life cycle of the thread in java is controlled by JVM. The java thread states are as follows:
1. New
2. Runnable
3. Running
4. Non-Runnable (Blocked)
5. Terminated
Java Applet
Applet is a special type of program that is embedded in the webpage to generate the dynamic
content. It runs inside the browser and works at client side.
Advantage of Applet
Drawback of Applet
o Plugin is required at client browser to execute applet.
Simple Applet
import java.awt.*;
import java.applet.*;
public class Simple extends Applet
{
public void paint(Graphics g)
{
g.drawString("A simple Applet", 20, 20);
}
}
String in Java
A string is a collection of characters. In Java, a string is an object that represents a collection of objects. A
string is a predefined class used to create string objects. It is an immutable object, which means it can’t be
updated once created.
class Main{
public static void main(String []args)
{
String s1="Adithya";
String s2="Adithya";
String s3="Adi";
boolean x=s1.equals(s2);
System.out.println("Compare s1 and s2:"+x);
System.out.println("Character at given position is:"+s1.charAt(5));
System.out.println(s1.concat(" the author"));
System.out.println(s1.length());
System.out.println(s1.toLowerCase());
System.out.println(s1.toUpperCase());
System.out.println(s1.indexOf('a'));
System.out.println(s1.substring(0,4));
System.out.println(s1.substring(4));
}
}
Code explanation
Lines 4-6: We create three strings s1, s2, and s3.
Line 7: We compare two strings s1 and s2 using equals() function.
Line 9: We find the character at position 5 in string s1 using charAt() function and print it.
Line 10: We concatenate two strings using the concat() function.
Line 11: We find the length of string s1 using length() function.
Line 12: We convert the string s1 to lowercase letters using toLowerCase() function.
Line 13: We convert the string s1 to uppercase letters using toUpperCase() function.
Line 14: We find the index of a in string s1 using indexOf() function.
Lines 15-16: We find the substring by passing indexes as parameters to the substring() function.
Events in Java
Events in Java represent the change in the state of any object. Events occur when the user interacts with the interface.
Clicking a button, moving the mouse, typing a character, selecting an item from a list, and scrolling the page are all
examples of behaviors that cause an event to occur.
Foreground Events: These events necessitate the user's direct participation. They are produced as a result of a user
interacting with graphical components in a Graphical User Interface.
Background Events: Background events are those that require end-user interaction. Operating system interrupts and
hardware or software failures are examples of background events.
Event handling in Java is the process of controlling an event and taking appropriate action if one occurs.
Components of Event Handling in Java
Events Handler
Event Sources
Event Listeners
1. Event Handler
An event handler is a function or method that executes program statements in response to an event. A software
program that processes activities such as keystrokes and mouse movements is what an event handler is. Event
handlers in Web sites make Web content dynamic.
2. Event Sources
An object on which an event occurs is referred to as a source. The source is in charge of informing the handler
about the event that occurred. There are various sources like buttons, checkboxes, lists, menu-item, choices,
scrollbars, text components, windows, etc.
3. Event Listeners
When an event occurs, an object named an event listener is called. The listeners need two things: first, they must
be registered with a source; however, they can be registered with multiple sources to receive event notifications.
Second, it must put in place the methods for receiving and processing notifications. A set of interfaces defines
the methods for dealing with events. The Java.awt.event package contains the following event classes and
interfaces.
Components: AWT provides various components such as buttons, labels, text fields, checkboxes, etc used for
creating GUI elements for Java Applications.
Containers: AWT provides containers like panels, frames, and dialogues to organize and group components in
the Application.
Layout Managers: Layout Managers are responsible for arranging data in the containers sone of the layout
managers are BorderLayout, FlowLayout, etc.
Event Handling: AWT allows the user to handle the events like mouse clicks, key presses, etc. using event
listeners and adapters.
Graphics and Drawing: It is the feature of AWT that helps to draw shapes, insert images and write text in the
components of a Java Application.
Note: Container can be added inside another container as it is type of component.
9. AWT Scrollbar
Syntax of AWT Scrollbar:
public class Scrollbar extends Component implements Adjustable, Accessible
Java AWT PopupMenu is a component that is used for dynamically popping up a menu that appears when the user
right-clicks or performs any other action on a component.
Syntax of AWT PopupMenu
public class PopupMenu extends Menu implements MenuContainer, Accessible
Types of LayoutManager
FlowLayout: It arranges the components in a container like the words on a page. It fills the top line
from left to right and top to bottom. The components are arranged in the order as they are added i.e. first
components appears at top left, if the container is not wide enough to display all the components, it is
wrapped around the line. Vertical and horizontal gap between components can be controlled. The
components can be left, center or right aligned.
BorderLayout: It arranges all the components along the edges or the middle of the container i.e. top,
bottom, right and left edges of the area. The components added to the top or bottom gets its preferred
height, but its width will be the width of the container and also the components added to the left or right
gets its preferred width, but its height will be the remaining height of the container. The components added
to the center gets neither its preferred height or width. It covers the remaining area of the container.
GridLayout: It arranges all the components in a grid of equally sized cells, adding them from the left to
right and top to bottom. Only one component can be placed in a cell and each region of the grid will have
the same size. When the container is resized, all cells are automatically resized. The order of placing the
components in a cell is determined as they were added.
GridBagLayout: It is a powerful layout which arranges all the components in a grid of cells and maintains
the aspect ration of the object whenever the container is resized. In this layout, cells may be different in
size. It assigns a consistent horizontal and vertical gap among components. It allows us to specify a default
alignment for components within the columns or rows.
BoxLayout: It arranges multiple components in either vertically or horizontally, but not both. The
components are arranged from left to right or top to bottom. If the components are aligned horizontally,
the height of all components will be the same and equal to the largest sized components. If the components
are aligned vertically, the width of all components will be the same and equal to the largest width
components.
CardLayout: It arranges two or more components having the same size. The components are arranged in
a deck, where all the cards of the same size and the only top card are visible at any time. The first
component added in the container will be kept at the top of the deck. The default gap at the left, right, top
and bottom edges are zero and the card components are displayed either horizontally or vertically.