Lecture18 - Java Programming, 3e Concepts and Techniques...

Info iconThis preview shows pages 1–12. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Java Programming, 3e Concepts and Techniques Chapter 4 Decision Making and Repetition with Reusable Objects (V) ICTN 2730 Lecture 18 02/22/2008 2 Chapter 4: Decision Making and Repetition with Reusable Objects 2 Assignments • Read chapter 4 and lecture notes. • Homework 6 is due next Wednesday. • Check the homework sample solutions and study the concepts you missed. • Quiz 2, covering chapters 3 - 4 and lectures 09- 18, will be available on Blackboard from 7 pm Sunday (2/24) till 9 pm Monday (2/25). 40 questions. Time limit: 70 minutes. For multiple choice questions, select the best answer. 3 Chapter 4: Decision Making and Repetition with Reusable Objects 3 CommissionApplet 4 Chapter 4: Decision Making and Repetition with Reusable Objects 4 CommissionApplet.java 5 Chapter 4: Decision Making and Repetition with Reusable Objects 5 Constructing Applet Components • Construct Labels for input and output • Construct a CheckboxGroup for user options 6 Chapter 4: Decision Making and Repetition with Reusable Objects 6 Constructing Applet Components • Add Labels and Checkboxes to the applet • Add an ItemListener to each Checkbox component with the addItemListener() method • Add color with the setForeground() and the setBackground() methods • Set the insertion point with the requestFocus() method 7 Chapter 4: Decision Making and Repetition with Reusable Objects 7 The init() Method 8 Chapter 4: Decision Making and Repetition with Reusable Objects 8 Handling Exceptions • Check for valid data when the itemStateChanged() method is triggered, which happens when the user clicks an option button 9 Chapter 4: Decision Making and Repetition with Reusable Objects Handling Exceptions try {…} catch (NumberFormatException e) { outputLabel.setText("You must enter a dollar amount greater than zero."); hiddenBox.setState(true); salesField.setText(""); salesField.requestFocus(); } 10 Chapter 4: Decision Making and Repetition with Reusable Objects 10 The getSales() Method • Parse the data from the TextField and return a valid sales amount or throw an exception to the init() method 11 Chapter 4: Decision Making and Repetition with Reusable Objects...
View Full Document

This note was uploaded on 04/29/2008 for the course ICTN 2730 taught by Professor Li during the Spring '08 term at East Carolina University .

Page1 / 29

Lecture18 - Java Programming, 3e Concepts and Techniques...

This preview shows document pages 1 - 12. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online