Java’s Coordinate System

To draw in Java, you must understand Java’s coordinate system (Fig. 4.17), a scheme for identifying points on the screen. By default, the upper-left corner of a GUI component has the coordinates (0, 0). A coordinate pair is composed of an x-coordinate (the horizontal coordinate) and a y-coordinate (the vertical coordinate). The x-coordinate is the horizontal location moving from left to right. The y-coordinate is the vertical location moving from top to bottom. The x-axis describes every horizontal coordinate, and the y-axis every vertical coordinate. Coordinates indicate where graphics should be displayed on a screen. Coordinate units are measured in pixels. The term pixel stands for “picture element.” A pixel is a ...

Get Java™ How To Program (Early Objects), Tenth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.