I can not understand the debug for class.
As a comment, the user needs to enter the pizza topping and it returns the price, there is a code in it, but I have no clue where to start on this debug.
Anything will help you, or even if you have a working code like it will help, I want to learn it, but if you need help, Thanks in advance for help / nudge.
// User selects pizza in the Dj Fender 3 and watches the price javax.swing. *; Import java.awt. *; Import java.awt.event. *; Use the correct spelling of the public class / class name DebugFourteen3 JFrame implies ItemListener {FlowLayout Flow = New Flow Layout (); JComboBox PizzaBox = New JComboBox (); JLab Topping List = New JLABEL ("Topping List"); J. Elabal Elabel = New JLABEL ("Polos American Pie"); JTextField totPrice = new JTextField (10); Int [] Pizza Price = {7,10,10,8,8,8,8}; Int totalPrice = 0; String output; Int pizzaNum; Public debugferant3 () {super ("pizza list"); SetDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); SetLayout (flow); PizzaBox.addItemListener (this); Add (toppingList); PizzaBox.addItem ("cheese"); PizzaBox.addItem ("sausage"); PizzaBox.addItem ("Pepperoni"); PizzaBox.addItem ("Onion"); PizzaBox.addItem ("green chilli"); PizzaBox.addItem ("green olive"); PizzaBox.addItem ("Black Olive"); Adding (pizzaBox); Add (aLabel); (Totalprice); } Public static zero main (string [] argument) {JFrame frame = new debug (3); Frame.setSize (200, 150); Frame.setVisible (true); } Public Zero ItemState Changed (Module [] list) {Object source = list.getSource (); If (source == pizzabox) {int pizzaNum = pizzaBox.getSelectedIndex (); Total value = pizza price [x]; Output = "pizza price $" + total value; TotPrice.setText (production); }}}
-
addition (totalprice);
is aint
, it can not be added to thecontainer
. - Use
JLabel
,JTextField
orJFormattedTextField
-
public There is no valid signature for the contractual requirements of the Zero ItemStat changel ({{code>
ItemListener
}. See the requirement method for signing, which will respect contractual requirements, which will take care of at least two other errors -
total value = pizza price [x];
,x
is undefined (or more than the point, it is defined as theprivate
variable incomponent
, and you have its Context, I think you wantpizzaNum
Personally, I think that you can only ItemListener
Instead of using the ActionListener
will be easy because you care only about the changes in the selected items, from the newly selected items to the newly selected items. Do not change
No comments:
Post a Comment