Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Difference between Swing and AWT in java?

Posted on 2004-03-23
9
Medium Priority
?
3,048 Views
Last Modified: 2013-11-23
What is difference between Swing and AWT in java and what do u mean by Heavyweight and lightweight component?
0
Comment
Question by:skirfan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
9 Comments
 
LVL 13

Accepted Solution

by:
Webstorm earned 100 total points
ID: 10657247
AWT generally use platform specific components, so look&feel is platform dependent.
Swing is a standard set of components whose look&feel is standard and can be changed (metal, windows, mac).

Heavyweight : native component
lightweight : component you create by subclassing the Component (or JComponent) class.
0
 
LVL 30

Assisted Solution

by:Mayank S
Mayank S earned 100 total points
ID: 10657253
Difference between Swing in Java? Let's say Swing has advanced features for everything that AWT has. Most of the things would have a 'J' prefixed. Like Frame will become JFrame, Dialog will become JDialog. But well, Swing gives you a lot more.... like the javax.swing.text package, the JEditorPane where you can display HTML/ plain-text (make a browser using that), JTree (if you wanna make Yahoo messenger ;-) ), JFileChooser, JOptionPane for customized dialog-boxes, JColorChooser, displaying images inside labels (JLabels), buttons (JButtons), etc
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 10657262
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.

The differences boil down to the following:

- A lightweight component can have transparent pixels; a heavyweight is always opaque.
- A lightweight component can appear to be non-rectangular because of  its ability to set transparent areas; a heavyweight can only be rectangular.
- Mouse events on a lightweight component fall through to its parent;  mouse events on a heavyweight component do not fall through to its parent.
- When a lightweight component overlaps a heavyweight component, the  heavyweight component is always on top, regardless of the relative z-order of the two components.

Courtesy: http://java.sun.com

http://java.sun.com/products/jfc/tsc/articles/mixing/
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 13

Expert Comment

by:Webstorm
ID: 10686362
Other important difference between lightweight and heavyweight components i tested (application & applet) :
    heavyweight component are still visibles when they are in an invisible lightweight container.

0
 
LVL 13

Expert Comment

by:Webstorm
ID: 10686372
And may be another one :
    Using a ScrollPane, the following AWT subtree:
          ScrollPane
          +---  lightweight component
    become when scrollpane is made visible:
          ScrollPane
          +---  Panel
                 +---  lightweight component

0
 
LVL 13

Expert Comment

by:Webstorm
ID: 10686407
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 10859152
Please proceed with that recommendation.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question