Java Swing O Reilly Swing uses a repaint (Web site layout)
Java Swing O Reilly Swing uses a repaint manager to repaint lightweight components. The repaint manager maintains a queue of rectangular areas that need to be repainted; it calls these areas ” dirty regions.” Sometimes the rectangles are the size of entire components; other times they are smaller. The repaint manager processes repaint requests as they are added to the queue, updating dirty regions as quickly as possible while preserving the visual order of the components. Recall that in AWT, the Componentclass contains an overloaded repaint() method that allows you to repaint only a subrectangle of the component. The same is true with JComponent. If only part of a component needs to be repainted, the repaint manager invokes an overloaded version of the repaint() method that takes a Rectangle parameter. JComponent contains two repaint() methods that each add specified rectangles directly to the dirty region. Like AWT, you want call upon these methods instead of invoking the paint() method directly, which bypasses the RepaintManager. The RepaintManager class is discussed in more detail in Chapter 28. 3.3.2.3 The paint( ) Method and Opaqueness Because JComponent is the direct subclass of the AWT Container class, it is the official recipient of repaint requests through its paint() method. As you might guess, JComponent must delegate this request by passing it on to the paint() method of the UI-delegate object. The responsibility, - 57 -
Check Tomcat Web Hosting services for best quality webspace to host your web application.