Solved

Difference between Swing and AWT in java?

Posted on 2004-03-23
9
2,900 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
  • 4
  • 3
9 Comments
 
LVL 13

Accepted Solution

by:
Webstorm earned 25 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:mayankeagle
mayankeagle earned 25 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:mayankeagle
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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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:mayankeagle
ID: 10859152
Please proceed with that recommendation.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
countX 22 70
mapShare challenge 13 69
Java asynchronous logging 4 34
recursion example 16 70
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

759 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now