Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Repairing And Querying Databases Under Aggregate Constraints

Authors: Sergio Flesca ,Filippo Furfaro ,Francesco Parisi

2011th Edition

146141640X, 978-1461416401

More Books

Students also viewed these Databases questions

Question

What are the purposes of promotion ?

Answered: 1 week ago

Question

The amount of work I am asked to do is reasonable.

Answered: 1 week ago

Question

The company encourages a balance between work and personal life.

Answered: 1 week ago