Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

JButton & Button ... etc. ?

Posted on 2004-09-01
7
Medium Priority
?
6,523 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 160 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
Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

 
LVL 92

Assisted Solution

by:objects
objects earned 160 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 240 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 240 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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…
Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses

705 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