Solved

JButton & Button ... etc. ?

Posted on 2004-09-01
7
6,252 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
[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
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
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
In this post we will learn different types of Android Layout and some basics of an Android App.
This video teaches viewers about errors in exception handling.
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.
Suggested Courses

623 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