Solved

JButton & Button ... etc. ?

Posted on 2004-09-01
7
5,124 Views
Last Modified: 2013-11-23
Hi Experts,

     What's the main difference between JButton and Button ? JFrame and Frame ? JLabel and Label ? It seems that JButton, JLabel and JFrame belong to swing and newer .... but .. what are the exact advantages of using them ? Thanks a lot !
0
Comment
Question by:meow00
7 Comments
 
LVL 35

Expert Comment

by:girionis
ID: 11949819
0
 
LVL 24

Assisted Solution

by:sciuriware
sciuriware earned 40 total points
ID: 11949821
SWING is a way to have components painted to any look and feel, even not provided
by the native platform.
The underlying AWT more or less conforms to the windowmanager program that does all the real painting.

This is just a way to describe it.
The best results come from using SWING with AWT to fill up the holes.
;JOOP!
0
 
LVL 92

Expert Comment

by:objects
ID: 11949840
the swing components (except the top level ones) are lightweight components, whereas the AWT ones are all heavyweights.
Heavyweights having an associated peer component from the native windoiw system.
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 92

Assisted Solution

by:objects
objects earned 40 total points
ID: 11949842
Swing offers far more functionality than AWT so unless your users don't have Swing support you should use the Swing ones ie. JBlahBlah's
0
 
LVL 1

Accepted Solution

by:
talvio earned 60 total points
ID: 11949848
Button and other GUI components not starting with J are part of AWT (Abstract Windowing Toolkit) which is the original Java GUI component set for Java. It was found to have problems in areas such as performance and flexibility which were then fixed by introducing Swing -components starting with J.

If you are doing desktop develoment I would recommend using Swing, IF there is no need to have backward compatibility to really old JVMs. AWT is still in use in J2ME (micro edition) in embedded devices for example. Swing and AWT should not be used together, although some AWT non-graphical components are used also in Swing.

There is also a commonly used widget set introduced by the eclipse project. I haven't tried it but it should be well worth looking into, if not otherwise atleast for pure interest. SWT (Standard Widget Toolki) and info about it can be found from: http://www.eclipse.org/swt/

br,
-jT

0
 
LVL 37

Assisted Solution

by:zzynx
zzynx earned 60 total points
ID: 11949853
Heavy vs. light: the differences

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.

The above is a quote from this article about mixing heavy and light components: http://java.sun.com/products/jfc/tsc/articles/mixing/
0
 
LVL 37

Expert Comment

by:zzynx
ID: 11950023
Thanks
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.

762 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

23 Experts available now in Live!

Get 1:1 Help Now