4.15 (Optional) GUI and Graphics Case Study: Creating Simple Drawings 35 In Cand C+ programmers f different computer pl requently have to wrte o write separate versions of to primitive types are not guaranteed to be identical from computer to computer. For example, an int on one machine might be represented by 16 bits (2 bytes) of memory, on a second machine by 32 bits (4 bytes), and on another machine by 64 bits (8 bytes). In Java, int values are always 32 bits (4 bytes) Portability Tip 4. The primitive types in Java are portable across all compauter platforms that support Java Each type in Appendix D is listed with its size in bits (there are eight bits to a byte) and its range of values. Because the designers of Java want to ensure portability, they use internationally recognized standards for character formats (Unicode; for more informa- tion, visit www.unicode.org) and floating-point numbers (IEEE 754; for more informa tion, visit grouper.ieee.org/groups/754/) Recall from Section 3.2 that variables of primitive types declared outside of a method as instance variables of a class are automatically asigned defauls values unless explicitly ini- tialized. Instance variables of types char, byte, short, int, long, float and double are all given the value O by default. Instance variables of type boolean are given the value false by default. Reference-type instance variables are initialized by default to the value null 4.15 (Optional) Gul and Graphics Case Study: Creating Simple Drawings An appealing feature of Java is its graphics support, which enables you to visually enhance your applications. We now introduce 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. 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 a-coordinate (the horizon- tal coordinate) and a y-coordinate (the vertical coordinate). The x-coordinate is the hor- izontal location moving from lefi to right. The y-coordinate is the vertical location moving from top to bottom. The a-axis describes every horizontal coordinate, and the y-axis every verticaloodinate. 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 display monitor's smallest unit of resolution. y-axis Fig. 4-17 | Java coordinate system, units are measured in pixels