Java Notes
Introduction to Components
Swing Components
You can draw things on the screen, but there are things that have already been made for you to put on the screen. These are called components. An example of a component is a label, button or scrollbar.The Java Swing classes provide the tools that help you build a good graphical user interface. You've already used some of the drawing methods. In this section you will learn to use Swing components.
Some advantages of using these components are:
- Java has already defined them along with a number of methods for customizing them.
- They paint themselves with their own paintComponent method, and redraw themselves as necessary when their state changes.
- They automatically position and resize themselves depending on the layout.
- Most allow user interaction which can result in calls to your methods to process the input.