AWT, APPLET- DIFFENCE?

My people in the house, I really appreciate your contributions to my questions.In addition, can someone explain AWT and Applet in details, and their difference?Thank you.
[191 byte] By [idomeena] at [2007-10-2 23:59:12]
# 1

ok, for starters, this question would be better posted in one of these forums:

http://forum.java.sun.com/forum.jspa?forumID=54

http://forum.java.sun.com/forum.jspa?forumID=31

http://forum.java.sun.com/forum.jspa?forumID=57

http://forum.java.sun.com/forum.jspa?forumID=5

anyway, you are basically trying to compare apples and oranges, and I think you'll understand why, when I explain what they are here. I'm also going to explain an alternative to AWT, which is SWING.

APPLETS:

An applet is a type of program that can be written in Java, which are usually intended to be embedded in web browsers. Hence, an applet has certain methods that allow it to interact with the web page in which it is embedded. It is also intended to be controlled by the web browser in which it is being run (for instance, an applet will suspend execution when the browser window is minimized). Because of this, and Applet has a well defined life cycle that starts with the init method. Beyond that, and applet is actually an AWT container, which is essentially a composite pattern (see Design Patterns by the Gang of Four) that you add other AWT (or SWING) components to, in order to create a Graphical User Interface (GUI) for your Applet. So basically, and Applet is 3 things:

1. A program with a predefined life cycle manager by the web browser in which it is running.

2. A program with an interface to interact with the web browser and web page in which it is running.

3. A top level container in which the Applet's GUI can be built.

AWT:

AWT was Sun's first attempt at creating GUI components for java. AWT is typically avoided in most cases, lately, by experienced java programmers (there are exceptions, but typically SWING is prefered). AWT consists of a set of standard widgets (called Components in java) that provide controls for applications. These widgets include command buttons, radio buttons, check boxes, combo boxes, list boxes, text boxes, etc. AWT also consists of a standard set of containers in which those widgets can be placed to visually organize them properly in the applet or application, along with the Layout Manager that assist in the correct placement of components. Finally, AWT provides a standard way to draw to the GUI without using components, by drawing directly to a graphics object. AWT can be use in Applets, but it can also be used in stand-alone applications. So to sum it up, AWT provides 3 things:

1. A standard set of GUI control widgets.

2. A means to lay out those widgets in a two dimensional space.

3. A way to abritrarily draw directly to the application's visual area.

SWING:

SWING is a prefered alternative to AWT. Swing consists of light-weight components, similar to those provided by AWT. The advantage of lightweight components is that they do not have to occupy their entire bounding box. Hence, what is behind the swing components can be visible in some areas, and the can take arbitrary shapes, rather than just rectangles. Another advantage to lightweight components is that they don't have to make calls to native peers to accomplish most of their tasks. Another thing SWING provides is the pluggable look and feel framework that allows a user to customize the way an application or applet looks by simply providing a different UI manager, or by providing different UI delegates to JComponents. Finally, SWING is MUCH bigger than AWT, providing a whole lot more components, customizable renders, high-level events and event handlers, customizable borders, excelent text processing components, and tons more. SWING has pretty well taken over AWT, so most of the new work gets done for SWING. So to sum it up, SWING is:

1. A bigger, more complete version of AWT

2. A Lightweight implementation of many of the components originally provided by AWT.

3. A highly customizable set of widgets that allows for much richer graphical applications than AWT.

So anyway, I hope that you now understand that AWT and SWING are frameworks for creating GUI's for both Applets and stand-alone Applications, and that Applets are a type of web application which are build on a heavy-weight AWT container, which is used as a base for creating the GUI of that Applet. So Applets and AWT are apples and oranges. They are completely different beasts.

- Adam

guitar_man_Fa at 2007-7-14 16:46:21 > top of Java-index,Other Topics,Patterns & OO Design...