Solved

JButton & Button ... etc. ?

Posted on 2004-09-01
7
6,040 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Maven Project: Hibernate Dependencies Conflict 10 93
spring jars download 1 68
null output 3 59
Running JavaFX on the Raspberry Pi 27 291
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
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:
Suggested Courses

739 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