ABSTRACT

So far, we have seen how to create menus and how to draw graphics and pictures on a panel. In this chapter, we will see how to display different graphic user interface (GUI) components inside a window. These include buttons, labels, text fields, text areas, combo boxes, check boxes, radio buttons, and so on. However, the goal of this chapter is not to list all GUI components that are available in Swing. Rather, we will list the main GUI components and we will show how to use them as part of building working software. We will also show how the components can be arranged inside a window and we will explore the flow layout, border layout, and grid layout. As part of presenting the material, working code for simple programs, such as converting Celsius to Fahrenheit, a calculator program, and a poor man’s version of Notepad, will be presented.