26.07.2013 Views

Java How to Program Fourth Edition - DCC

Java How to Program Fourth Edition - DCC

Java How to Program Fourth Edition - DCC

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 12 Graphical User Interface Components: Part 1 717<br />

12.9 Create the following GUI. You do not have <strong>to</strong> provide any functionality.<br />

12.10 Create the following GUI. You do not have <strong>to</strong> provide any functionality.<br />

12.11 Create the following GUI. You do not have <strong>to</strong> provide any functionality.<br />

12.12 Write a temperature conversion program that converts from Fahrenheit <strong>to</strong> Celsius. The Fahrenheit<br />

temperature should be entered from the keyboard (via a JTextField). A JLabel should<br />

be used <strong>to</strong> display the converted temperature. Use the following formula for the conversion:<br />

Celsius = 5 / 9 × ( Fahrenheit – 32 )<br />

12.13 Enhance the temperature conversion program of Exercise 12.12 by adding the Kelvin temperature<br />

scale. The program should also allow the user <strong>to</strong> make conversions between any two scales.<br />

Use the following formula for the conversion between Kelvin and Celsius (in addition <strong>to</strong> the formula<br />

in Exercise 12.12):<br />

Kelvin = Celsius + 273<br />

12.14 Write an application that allows the user <strong>to</strong> draw a rectangle by dragging the mouse on the<br />

application window. The upper-left coordinate should be the location where the user presses the<br />

mouse but<strong>to</strong>n, and the lower-right coordinate should be the location where the user releases the mouse<br />

but<strong>to</strong>n. Also display the area of the rectangle in a JLabel in the SOUTH region of a BorderLayout.<br />

Use the following formula for the area:<br />

area = width × height<br />

12.15 Modify the program of Exercise 12.14 <strong>to</strong> draw different shapes. The user should be allowed<br />

<strong>to</strong> choose from an oval, an arc, a line, a rectangle with rounded corners and a predefined polygon.<br />

Also display the mouse coordinates in the status bar.<br />

© Copyright 1992–2002 by Deitel & Associates, Inc. All Rights Reserved. 7/7/01

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!