4.14. (Optional) GUI and Graphics Case Study: Creating Simple Drawings
One of Java’s appealing features is its graphics support that enables programmers to visually enhance their applications. This section introduces one of Java’s graphical capabilities—drawing lines. It also covers the basics of creating a window to display a drawing on the computer screen.
To draw in Java, you must understand Java’s coordinate system (Fig. 4.18), a scheme for identifying every point 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 ...
Get Java™ How to Program, Seventh 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.