[Page 397] The Goddess Chalchihuitlicue, found in the Valley of Mexico, 1300-1500 AD (stone), Aztec / Muse de l'Homme, Paris, France / Bridgeman Art Library
Part 1, "Fundamentals of Programming," introduced basic programming concepts that are supported in all programming languages. Part 2, "Object-Oriented Programming," introduced object-oriented programming concepts, principles, and practices that are common in the object-oriented programming languages. Java is not simply a programming language. It is also a development and deployment platform with an extensive set of classes and interfaces in the API. You have to use the classes and interfaces in the API and follow their conventions and rules to develop your own projects. The design of the API for Java GUI programming is an excellent example of how the object-oriented principle is applied. In the chapters that follow, you will learn the framework of Java GUI API and use the GUI components to develop user -friendly interfaces for applications and applets.
[Page 398] Prerequisites for Part 3
Part 3, "GUI Programming," may be intertwined with Part 2, "Object-Oriented Programming." You can cover GUI programming in Chapters 12 and 13, "Getting Started with GUI Programming" and "Graphics," after you have covered abstract classes in Chapter 10, "Abstract Classes and Interfaces."
Interfaces in Chapter 10, "Abstract Classes and Interfaces," can be covered just before Chapter 14, " Event-Driven Programming ."
The concept and simple examples of using applets can be covered earlier after Chapter 12, "GUI Basics."
| Chapter 12 Getting Started with GUI Programming | |
| Chapter 14 Event-Driven Programming | |
| Chapter 15 Creating User Interfaces | |
| Chapter 16 Applets and Multimedia | |
[Page 399] Chapter 12. Getting Started with GUI Programming
Mayan God Shel, Mexico. Photographer: Philip Coblentz. Courtesy Brand X Pictures
[Page 400] 12.1. Introduction
Until now, you have only used dialog boxes and the command window for input and output. You used JOptionPane.showInputDialog to obtain input, and JOptionPane.showMessageDialog and System.out.println to display results. These approaches have limitations and are inconvenient. For example, to read ten numbers , you have to open ten input dialog boxes. Starting with this chapter, you will learn Java GUI programming. You will create custom graphical user interfaces (GUI, pronounced goo-ee ) to obtain input and display output in the same user interface.
This chapter introduces the basics of Java GUI programming. Specifically, it discusses GUI components and their relationships, containers and layout managers, colors, fonts, borders, and tool tips.