dummies logo
Articles

Article Categories

close
TechnologyAcademics & The ArtsHome, Auto, & HobbiesBody, Mind, & SpiritBusiness, Careers, & Money
Collections

Collections

Explore all collections
close
BYOB (Be Your Own Boss)Be a Rad DadCareer ShiftingContemplating the CosmosFor Those Seeking Peace of MindFor the Aspiring AficionadoFor the Budding Cannabis EnthusiastFor the College BoundFor the Exam-Season CrammerFor the Game Day Prepper
Custom Solutions
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
forward arrow
  • Custom Solutions
  • Main Menu
  • Collections

    Explore all collections
    • BYOB (Be Your Own Boss)
    • Be a Rad Dad
    • Career Shifting
    • Contemplating the Cosmos
    • For Those Seeking Peace of Mind
    • For the Aspiring Aficionado
    • For the Budding Cannabis Enthusiast
    • For the College Bound
    • For the Exam-Season Crammer
    • For the Game Day Prepper
    Before you jump into Java GUIs, there are a few things you should know. Java comes with three sets of classes for creating GUI applications:
    • The Abstract Window Toolkit (AWT): The original set of classes, dating back to JDK 1.0.

    Classes in this set belong to packages whose names begin with java.awt. Components in this set have names like Button, TextField, Frame, and so on.

    Each component in an AWT program has a peer — a companion component that belongs to the computer's own operating system. For example, when you create an AWT Button, a Mac computer creates its own kind of button to be displayed on the user's screen. When the same program runs on a Windows computer, the Windows computer creates a different kind of button (a Windows button) to display on the computer's screen. The Java code in the AWT interacts with the Mac or Windows button, adding additional functionality where functionality is needed.

    The AWT implements only the kinds of components that were available on all common operating systems in the mid-1990s. So, using AWT, you can add a button to your application, but you can't easily add a table or a tree.

    • Java Swing: A set of classes created to fix some of the difficulties posed by the use of the AWT. Swing was introduced in J2SE 1.2.

    Classes in this set belong to packages whose names begin with javax.swing. Components in this set have names like JButton, JTextField, JFrame, and so on.

    Unlike an old AWT component, a Swing component has no peer. When you create a JButton in your Java program, the computer's operating system doesn't create a button of its own. Instead, the JButton that you see is a pure Java object. Java's visual rendering code draws this object on a window. This is both good news and bad news. The good news is, a Swing program looks the same on every operating system. In a Swing program, you can create table components and tree components because Java simply draws them in the computer's window. The bad news is, Swing components aren't pretty. A JButton looks primitive and crude compared to a Mac button or a Windows button.

    Java's Swing classes replace some (but not all) of the classes in the older AWT. To use some of the Swing classes, you have to call on some of the old AWT classes.

    • JavaFX: The newest set of GUI classes in Oracle standard Java. JavaFX comes with new(er) versions of Java 7 and with all later versions of Java.

    Classes in this set belong to packages whose names begin with javafx.

    JavaFX supports over 60 kinds of components. (Sure, you want a Button component. But do you also want an Accordion component? JavaFX has one.) In addition, JavaFX supports multitouch operations and takes advantage of each processor's specialized graphics capabilities.

    About This Article

    This article is from the book: 

    Beginning Programming with Java For Dummies

    About the book author:

    Dr. Barry Burd holds an M.S. in Computer Science from Rutgers University and a Ph.D. in Mathematics from the University of Illinois. Barry is also the author of Beginning Programming with Java For Dummies, Java for Android For Dummies, and Flutter For Dummies.

    This article can be found in the category: 

    Java
    Trending
    How to Write Effective AI Prompts for Different Real World Uses
    Captain America For Dummies Cheat Sheet
    MacOS Monterey For Dummies Cheat Sheet
    What Are Somatic Exercises and Their Benefits?
    From Category
    Java
    Important Features of the Java Language
    How to Download and Install TextPad
    How to Install JavaFX and Scene Builder
    Getting a Value from a Method in Java
    Let the Objects Do the Work in Java

    Quick Links

    About For Dummies
     Terms of Use
    Copyright © 2000-2025 by John Wiley & Sons, Inc., or related companies. All rights reserved, including rights for text and data mining and training of artificial technologies or similar technologies.
    © 2025 MARVEL

    Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

    Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant