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.