Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Standard view
Full view
of .
Look up keyword
Like this
0 of .
Results for:
No results containing your search query
P. 1
AWT Components 1

AWT Components 1

Ratings: (0)|Views: 131|Likes:
Published by api-3749401

More info:

Published by: api-3749401 on Oct 16, 2008
Copyright:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as DOC, PDF, TXT or read online from Scribd
See more
See less





AWT Components

The basic idea behind the AWT is that a java window is a set of nested components starting from the outermost window all the way down to the smallest User Interface component.

The AWT classes are contained in the java.awt package. It is one of the
java\u2019s largest packages.

The AWT provides the basic GUI components that are used in java applets and applications. The AWT provides a machine-independent interface for applications.

The AWT classes provides the following:
A fell set of UI widgets and other components, including windows,
menus, buttons, checkboxes etc.
Support for UI containers, which can contain other embedded
containers and widgets.
Provision of Layout Managers whose duty is to handle the laying out
of components on Containers.
An event system for managing system and user events between and
among parts of the AWT

Java Components are implemented by the many subclasses of the java.awt.Component and java.awt.MenuComponent superclass. There are 19 non-superclasses in general. The general way to categories them is to divide them into the following categories:

Visual Components
Container Components
Menu Components
The fundamental visual controls in java are:

1. Label \u2013 A simple label
2. Button \u2013 A simple push button
3. Canvas \u2013 A base class for creating your own controls.
4. Checkbox \u2013 A combination of check box and radio (option) button
5. Choice \u2013 A drop down list control
6. FileDialog \u2013 Which represents a File Open or Save Dialog

7. List \u2013 A list box
8. Scroll bar \u2013 Horizontal and Vertical Scroll bar
9. Scroll Pane \u2013 A scrollable pane where areas of larger components can
be shows
10. Text Field \u2013 A single line text entry field
11. Text Area \u2013 A multiple line text entry field
The most common methods in the Object and Component classes are:
1. setBounds
Changes control shape and location
2. setSize
Changes control size
3. setEnabled
Sets control to active or inactive
4. setBackground
Sets background color
5. getBackground
Gets background color
6. isEnabled
Returns boolean indicating whether currently
7. isVisible
Returns boolean indicating whether control is
8. getLocation
Returns the x and y location
9. setLocation
Moves the control to a new location
Asks system to give focus to control
Sets Background Color
Sets Foreground Color
Sets font to font , style and size
Returns the current size of control
The containers contain individual components inside them.

The two important things done with the container is establishing the container\u2019s layout manager and adding components to the container. Container is the abstract subclass of component, which allows other components to be nested inside it. These components can also be containers allowing other components to be nested inside it.

1. Window \u2013 It is a freestanding native window on the display. Window

has Frame and Dialog as its subclasses
2. Frame \u2013 A frame is a window with a title and resizing corners.
3. Dialog \u2013 A Dialog does not have a menu bar. Although u can move it,

you cannot resize it.

4. Panel \u2013 It is contained inside another container of inside a web browser\u2019s window. Panel identifies a rectangular area into which you must place other components. You must place Panel into a Window or subclass of window to be displayed.


Incase u are not using the default layout managers associated with each container, we must ourselves place the components using the 3 methods \u2013 setLocation(), setSize() and setBounds().


The layout manager can override your decision. If you must control the size or position of components in such a way that cannot be done using the standard layout managers, you can disable the layout manager by issuing the following method call in your container

Con.setLayout (null); after this u are responsible for the positioning of the
The methods of the class Container are:
Sr. No Method
Component add (Component c)
Adds the specified component to
the end of this container
Component add (Component c,
int pos)

Adds the specified component to this container at the given position. Here the number would be \u20131 to insert at the end

int getComponentCount ()
Gets the number of components in
the container.
Component getComponent (int n) Gets the specified Component
LayoutManager getLayout ()
void remove (Component c)
Remove the specified Component

You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->