This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
I'm new to all this and being the only girl in class, I get so frustrated because I can't get this to work right. All I want to do is use checkbox, say for 5 of them and total them up here is my code can some one help me? import java.awt.*; import java.applet.*; import java.awt.event.*;
public class PetClinicApplet extends Applet implements ItemListener, ActionListener { //Create components for applet Label companyNameLabel = new Label(" LIONS, TIGERS, AND BEARS "); Label welcomeLabel = new Label(" Welcome! "); Label variousServiceLabel = new Label(" Please check services being used. "); Checkbox officeVisitBox = new Checkbox("Office Visits "); Checkbox hospitalBox = new Checkbox("Hospitalization "); Checkbox vaccinBox = new Checkbox( "Vaccinations "); Checkbox boardBox = new Checkbox("Boarding "); Checkbox dentistBox = new Checkbox("Denistry "); Checkbox xrayBox = new Checkbox("X-rays "); Checkbox labBox = new Checkbox("Laboratory Work "); Checkbox heartwormPrevBox = new Checkbox("Heartworm Prevention"); Checkbox prescripBox = new Checkbox("Prescriptions "); Label outputLabel = new Label(); Label outputLabel1 = new Label(); Button calcButton = new Button("Calculate Totals");
public void init() { //Add components to window and set colors setBackground(Color.gray); setForeground(Color.black); add(companyNameLabel); add(welcomeLabel); add(variousServiceLabel); add(officeVisitBox); officeVisitBox.addItemListener(this); add(hospitalBox); hospitalBox.addItemListener(this); add(vaccinBox); vaccinBox.addItemListener(this); add(boardBox); boardBox.addItemListener(this); add(dentistBox); dentistBox.addItemListener(this); add(xrayBox); xrayBox.addItemListener(this); add(labBox); labBox.addItemListener(this); add(heartwormPrevBox); heartwormPrevBox.addItemListener(this); add(prescripBox); prescripBox.addItemListener(this); add(calcButton); calcButton.addActionListener(this); add(outputLabel); add(outputLabel1);
//Assigning Values int officeVisitBox = 35; int hospitalBox = 75; int vaccinBox = 25; int boardBox = 15; int dentistBox = 25; int xrayBox = 12; int labBox = 20; int heartwormPrevBox = 12; int prescripBox = 9;
} public void itemStateChanged(ItemEvent choice) {
int total; total = //Display Output outputLabel1.setText("The total amount is $" + (total)); outputLabel.setForeground(Color.black);