Java Swing Tutorials - Herong's Tutorial Examples

http://www.herongyang.com/Swing

Copyright © 1997-2018 by Dr. Herong Yang. All rights reserved.

Java Swing Tutorials This tutorial book is a collection of notes and sample codes written by the author while he was learning Java Swing and AWT himself. Topics include Swing and AWT (Abstract Windows Toolkit) class library; graphical components: JFrame, JLabel, JButton, JRadioButton, JTextField; frame layouts; menus; dialog boxes; editor pane; Unicode and Chinese.

Table of Contents

About This Book

JDK (Java Development Kit)

What Is JDK

Downloading and Installing JDK 10

Writing My First Java Program

Adding JDK "bin" Directory to Path Setting

JDK Documentation Installation

Introduction of Java Swing Package

What Is Swing

SwingHello.java - My First Swing Program

Graphics Environment of the Local System

java.awt.GraphicsEnvironment - Graphics Environment Class

java.awt.Toolkit - AWT Base Class

Testing Screen Resolution

JFrame - Main Frame Class

Creating Frames with Sizes and Locations

Closing Frame and Terminating Application

Listing and Interrupting AWT Threads

"AWT blocker activation interrupted" Error

"AWT blocker activation interrupted" Error in JDK 1.8

Displaying Chinese Characters in Frame Title

Drawing Graphics - Using paint() on Frame

Drawing Graphics - Using paint() on Component

Drawing Graphics - Using paint() on Content Pane

Drawing Chinese Characters on Frames

JLabel - Swing Label Class

Creating Labels with javax.swing.JLabel Class

Creating Labels with Chinese Characters

JButton - Swing Button Class

Creating Buttons with javax.swing.JButton Class

Creating Image Buttons with javax.swing.JButton Class

Button Action Handler at the Component Level

Button Action Handler at the Frame Level

Mouse Click Handler at the Frame Level

JRadioButton - Swing Radio Button Class

javax.swing.JRadioButton and Related Classes

ActionListener, ChangeListener and ItemListener

getSelection() - Getting Selected Button

JTextField - Swing Text Field Class

javax.swing.JTextField and Related Classes

ActionListener and DocumentListener

Menu Bar, Menus, Menu Items and Listeners

JMenuBar, JMenu, and JMenuItem Classes

JMenuBarTest.java - Menu Bar Test Program

JMenuTest.java - Menu Test Program

JMenuItemTest.java - Menu Item Test Program

JRadioButtonMenuItemTest.java - Radio Button Menu Item Test Program

JCheckBoxMenuItemTest.java - Check Box Menu Item Test Program

javax.swing.event.MenuListener - Menu Listener Interface

JMenuItemActionListenerTest.java - Menu Item Action Listener Test

Item Listener on Radio Button Menu Items

Item Listener on Check Box Menu Items

javax.swing.event.MenuKeyListener - Menu Key Listener Interface

setMnemonic() - Setting Keyboard Mnemonics on Menu Items

setAccelerator() - Setting Keyboard Accelerators on Menu Items

setMnemonic() - Setting Keyboard Mnemonics on Menus

Creating Internal Frames inside the Main Frame

javax.swing.JInternalFame - Internal Frame Class

JInternalFameTest.java - Internal Frame Class Test

javax.swing.InternalFrameListener - Internal Frame Listener Interface

Layout of Components in a Container

LookAndFeel and UIManager

Option Dialog Boxes

JEditorPane - The Editor Pane Class

SwingWorker - The Background Task Worker

AWT (Abstract Windows Toolkit)

What Is AWT (Abstract Windows Toolkit)

HelloAWT.java - My First AWT Program

Closing AWT Frame and Terminating Application

Drawing Graphics - Using paint() on Frame or Component

Creating Labels with java.awt.Label Class

Creating Buttons with java.awt.Button Class

AWT Button Action Handler at the Component Level

AWT Button Action Handler at the Frame Level

AWT Button Mouse Click Handler at the Frame Level

AWT TextField and ActionListener

MenuBarTest.java - AWT Menu Bar Test Program

MenuTest.java - AWT Menu Test Program

MenuItemTest.java - AWT Menu Item Test Program

MenuItemActionListenerTest.java - AWT Menu Item Action Listener

References

Full Version in PDF/EPUB

Keywords: Swing, AWT, Java, Graphics, User Interface