The following three methods are involved in displaying graphics. These two methods, along with the repaint() method, are discussed in the next section. An instance is typically created by a component, and handed to the program as an argument to a component's update() and paint() methods. Because the Graphics class is an abstract base class, it cannot be instantiated directly. In order to draw, a program requires a valid graphics context (represented by an instance of the Graphics class). All output to the graphics destination occurs via an invocation of one of these methods. Second, the Graphics class provides methods for drawing simple geometric shapes, text, and images to the graphics destination. It even includes information about the eventual destination of the graphics operations themselves (screen or image). This includes the background and foreground colors, the font, and the location and dimensions of the clipping rectangle (the region of a component in which graphics can be drawn). The graphics context is information that will affect drawing operations. It plays two different, but related, roles. The Graphics class provides the framework for all graphics operations within the AWT. It's essential that programmers understand the Graphics class before they attempt to draw images via Java. Let's begin at center stage - the Graphics class.
0 Comments
Leave a Reply. |