13.16. Review Questions

 
[Page 426 ( continued )]

13.2. Graphical Coordinate Systems

To paint, you need to know where to paint. Each component has its own coordinate system with the origin ( 0, 0 ) at the upper-left corner of the component. The x coordinate increases to the right, and the y coordinate increases downward. Note that the Java coordinate system is different from the conventional coordinate system, as shown in Figure 13.1. The location of the upper-left corner of a component c1 (e.g., a button) inside its parent component c2 (e.g., a panel) can be located using c1.getX() and c1.getY() , as shown in Figure 13.2.

Figure 13.1. The Java coordinate system is measured in pixels, with (0, 0) at its upper-left corner.

Figure 13.2. Each GUI component has its own coordinate system.

 


Introduction to Java Programming-Comprehensive Version
Introduction to Java Programming-Comprehensive Version (6th Edition)
ISBN: B000ONFLUM
EAN: N/A
Year: 2004
Pages: 503

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net