Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help debugging this. the answers that exist already under the textbook is incorrect. import javax.swing.*; import java.awt.*; import java.awt.event.*; public class DebugFourteen2 extends

I need help debugging this. the answers that exist already under the textbook is incorrect.

import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

public class DebugFourteen2 extends JFrame implements ItemListener

{

FlowLayout flow = new FlowLayout();

JComboBox payMethod = new JComboBox();

JLabel payList = new JLabel("Pay List");

JTextField totFees = new JTextField(25);

String pctMsg = new String("per cent will be added to your bill");

int[] fees = {5, 2, 0};

int feePct = 0;

String output;

//int fee = 0;

public DebugFourteen2()

{

super("Pay List");

setDefaultClosetOperation(JFrame.EXIT_ON_CLOSE);

setLayout(flow);

payMethod.addItemListener(this);

add(payList);

add(payMethod);

payMethod.addItems("Credit card");

payMethod.addItems("Check");

payMethod.addItems("Cash");

add(totFees);

}

public static void main(String[] arguments)

{

//JFrame cframe = new DebugFourteen2();

DebugFourteen2 cframe = new

DebugFourteen2();

cframe.setSize(350,150);

cframe.setVisible(true);

}

//@Override

public void itemStateChanged(ItemEvent list)

{

Object source = list.getSource();

if(source == payMethod)

{

int fee = payMethod.getSelectedIndex();

feePct = fees[fee];

output = feePct + " " + pctMsg;

totFees.setText(output);

}

}

}

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

Step: 3

blur-text-image

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

Excel As Your Database

Authors: Paul Cornell

1st Edition

1590597516, 978-1590597514

More Books

Students also viewed these Databases questions