this is vinay
1. swing is light weight component and awt is heavy weight
2. swing components require javax.swing package where as
awt comonents require java.awt package
3. awt requres native code to execute/run but not swings
4. swing are also known as JFC's
5. swing is a look and feel component and it is purely
developed in java.
Most of the issues related to mixing AWT and Swing
components are related to the mixing of so-called
heavyweight and lightweight components. A heavyweight
component is one that is associated with its own native
screen resource (commonly known as a peer). A lightweight
component is one that "borrows" the screen resource of an
ancestor (which means it has no native resource of its
own -- so it's "lighter").
(Lightweight component support was introduced in JDK1.1,
and you can read more about it in the
We generally don't recommend mixing Swing and AWT
components because there are significant benefits in
sticking with programs that are written entirely in Swing
(and thus use only lightweight components).
Some of the benefits of using Swing components are:
More efficient use of resources: Lightweight
components are really "lighter" than heavyweight
More consistency across platforms because Swing is
written entirely in Java.
Cleaner look-and-feel integration: You can give a
set of components a matching look-and-feel by implementing
them using Swing.
Despite the benefits of using Swing components exclusively,
a developer may sometimes have to mix AWT components and
Swing components in the same program (even when migration
is not to blame). For example, such mixing may be required
when a Swing version of a particular AWT component is not
Because there's sometimes no alternative to mixing
heavyweight and lightweight components, we have provided a
few options in Swing to make a certain level of component-
mixing possible. However, as anyone who has tried this
approach knows, there are some practical limitations to
There are some significant differences between lightweight
and heavyweight components. And, since all AWT components
are heavyweight and all Swing components are lightweight
(except for the top-level ones: JWindow, JFrame, JDialog,
and JApplet), these differences become painfully apparent
when you start mixing Swing components with AWT components.
1. Awt components are heavy weight whereas swing components are light weight, heavy weight are those which are os dependent.
2. A swing has extra components like table,tree,optionalpanel with the class named JTree,JTable,JOptionalPane etc.
3. Swing components support MVC (model,view,control architecture) whereas awt components support Delegate Event Model.
4. Swing components provide dynamic look and feel whereas awt components provide static look and feel.
the awt is the base, its components are heavy weight as they are operating system dependent.To solve this problem we introduce swing
the swing self built components which are not inherited from awt are light weight .Still a major problem with swing
is that the components it inherited from awt are atill heavy this problem is solved by hidden container ContentPane which u can get by method getContentPane()
The classes contained in the java.awt package provide a
basic capability to create graphical user interfaces, but
the scope of the tools contained in java.awt is limited.
Furthermore, the actual implementation of the components is
done in a language other than Java, and the look and
behavior of the components is somewhat dependent on the
runtime platform's native environment. AWT components might
act slightly differently on a UNIX system than they would on
The Swing classes are the next-generation (Java 2) GUI
classes. They provide a number of new components including
trees, tables, and tooltips, etc. Swing components are
written entirely in Java...
You can read more about swing here :
AWT components use native methods whereas Swing components
use the methods that are written in Java.
AWT components are Heavy weight and Swing components are
Awt is not platform independent where as swing is platform
when i run Frame program, it display output in supparate
window.i try to close using "X" it not close.min'-' &
max'+' are working.pls what is problem? i run in editplus.
folowing program i given.
Frame f1=new Frame("loginpage");
Label l1=new Label("username");
Label l2=new Label("password");
TextField tf1=new TextField();
TextField tf2=new TextField();
Button b1=new Button("submit");
public static void main(String args)
Form1 f=new Form1();