Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword
Like this
5Activity
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

Availability:

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

03/18/2014

pdf

text

original

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)
A fell set of UI widgets and other components, including windows,
menus, buttons, checkboxes etc.
b)
Support for UI containers, which can contain other embedded
containers and widgets.
c)
Provision of Layout Managers whose duty is to handle the laying out
of components on Containers.
d)
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:

a)
Visual Components
b)
Container Components
c)
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
enables
7. isVisible
Returns boolean indicating whether control is
visible
8. getLocation
Returns the x and y location
9. setLocation
Moves the control to a new location
10.
requestFocus
Asks system to give focus to control
11
.
getBackground
Sets Background Color
12.
getForeground
Sets Foreground Color
13.
setFont
Sets font to font , style and size
14.
getSize
Returns the current size of control
Containers
-
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
components.
The methods of the class Container are:
Sr. No Method
Description
1
Component add (Component c)
Adds the specified component to
the end of this container
2
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

4
int getComponentCount ()
Gets the number of components in
the container.
5
Component getComponent (int n) Gets the specified Component
6
LayoutManager getLayout ()
Gets
the
container\u2019s
LayoutManager
7
void remove (Component c)
Remove the specified Component

You're Reading a Free Preview

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