CHAPTER 60 — Swing Text Fields and Labels

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.
go to home page   go to next page

created: 6/28/99; revised 01/27/00 (using AWT); major revision: 01/10/02 (using Swing); 07/17/06; refurbished 11/02/08

CHAPTER 60 — Swing Text Fields and Labels

This chapter introduces Swing text fields and labels and uses them in a simple Swing program.

Chapter Topics:

  • The JTextField Swing component.
  • The setText() and getText() methods of JTextField.
  • The JLabel GUI Component.
  • Using ActionListener for a JTextField's event.
  • Example program: text echo program.
  • The setEditable() method of JTextField.

QUESTION 1:

(Review: ) Say that you have just finished your Swing application. You compile it and start it running. You click on a button and..... nothing happens. What might be wrong?