Java Swing O Reilly however, does not end (Free web hosting with ftp)

Java Swing O Reilly however, does not end there. JComponent is actually responsible for painting three items: the component itself, any borders associated with the component, and any children that it contains. The order is intentional. Swing assumes that the components drawn last are always on top; hence, child components always paint over their parents. JComponent contains three protected methods that it uses to complete this functionality: paintComponent() paintBorder() paintChildren() Because of the complexity involved in painting and repainting Swing components, you should always try to override these three methods while creating your own components. Again, do not try to override paint() unless you call superpaint() while you’re at it. The boolean property opaque dictates the transparency of each Swing object.[2] If this property is set to false, the component’s background color is transparent. This means that any areas left untouched by the component’s rendering allow graphics in the background to show through. If the property is set to true, the rectangular painting region is completely filled with the component’s background color before it is rendered. Incidentally, transparency was not possible before lightweight components. Native peer objects in Java 1.0 always drew their component on a solid rectangle; anything that was behind the component was erased. Figure 3.5 shows the difference between an opaque and a transparent (non-opaque) label without a dark background color. The label on the left is transparent, so its background color is ignored; the label’s text appears on top of the container’s relatively light background. [2] In JDK1.2, the isOpaque() method is defined in java.awt.Component. Figure 3.5. Transparency and opaqueness JComponent can optimize its repainting time if none of its children overlap; this is because the repaint manager does not have to compute the hidden and visible areas for each child component before rendering them. Some containers, such as JSplitPane, are designed so that overlap between child components is impossible, so this optimization works nicely. Other containers, such as JLayeredPane, have support for child components that can overlap. JComponent contains a property that Swing frequently calls upon to see if it can optimize component drawing: optimizedDrawingEnabled . In JComponent, the property is set to true by default. If overlap occurs in a subclass of JComponent, the subclass should override the isOptimizedDrawingEnabled() accessor and return false. This prevents the repaint manager from using the optimized drawing process when rendering the container’s children. JComponent contains a boolean read-only property paintingTile that indicates whether the component is currently in the process of painting a tile that is, a child component that does not overlap any other children. The isPaintingTile() method will return true until all tiles have been painted. - 58 -
Please visit Domain Name Hosting services for high quality webhost to host and run your jsp applications.