Solved

JButton & Button ... etc. ?

Posted on 2004-09-01
7
5,441 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deletiā€¦
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

786 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