I'm getting a bunch of errors in Java, I do not know where to start from I'm new to GUI programming And you will appreciate any help you can provide or even press any tube in the right direction.
Here is my current code:
// DebugFourteen2 // Displays a list of payment options // - using credit card, check or cash / each Shows charges for - 5%, 2% or 0% import javax.swing. *; Import java.awt. *; Import java.awt.event. *; Public class Debug Forbah 2 applies to Juffrum Item Listener {Flow Layout Flow = New Flow Layout (); JComboBox payMethod = New JComboBox (); JAlabel Peleste = new JLABEL ("pay list"); JTextField totFees = new JTextField (25); String pctMsg = new string ("percent will be added to your bill"); Int [] Fees = {5, 2, 0}; Int FPTT = 0; String output; Int fee = 0; Public Zero DebugFourteen2 () {super ("pay list"); SetDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); SetLayout (flow); PayMethod.addItemListener (); Adding (payList); Add (payMethod); Pamthip.editem ("credit card"); PayMethod.addItem ("check"); PayMethod.addItem ("cash"); (TotFees); } Public static zero main (string [] argument) {JFrame cframe = new DebugFourteen2 (); Cframe.setSize (350, 150); Cframe.setVisible (true); } Public Zero ItemState Changel (Object Extension List) {Object Source = list.getSource (); If (source = payment) int fees = paythipat Selected Index (); FeePCT = fees [x]; Output = feature + + + + + pctMsg; TotFees.setText (production); }}
There you go, it compiles and you can run it (Use my code below): OUTPUT:
< / P>
You are so many mistakes .. (This is probably a homework that asks you to fix this code which does not compile):
1) ">` ` In line, no Java code can compile this line
2)
payMethod.addItemListener ();
to < Code > PayMethod.addItemListener (this); or the listener has not worked in Java.
3) FePTty = fees [x];
should be converted to feePct = fees [fees];
because your code is not easily x
.
4) < Strong> ` on the last line .. Any Java program will ever run at the end of any class of this class ...
5) @ Tom has mentioned in his comment, Incorrect and unnecessary int fee = pa YMethod.getSelectedIndex ();
You int charges = 0;
have already been declared (and can not do this because it is a mistake) Reclaim it as int fee = payMethod.getSelectedIndex ();
.. just fee = pay-mathidet Selected Index ();
is sufficient
// debugoforin 2 // display list payment option // - shows the charge for the use of each credit card, check or cash / - 5%, 2 % Or 0% import javax.swing *; Import java.awt. *; Import java.awt.event. *; Public Class Debug Forbah 2 applies to Juffrum Item Listener {Flow Layout Flow = New Flow Layout (); JComboBox payMethod = New JComboBox (); JAlabel Peleste = new JLABEL ("pay list"); JTextField totFees = new JTextField (25); String pctMsg = new string ("percent will be added to your bill"); Int [] Fees = {5,2,0}; Int FPTT = 0; String output; Int fee = 0; Public debugging 2 () {// super ("pay list"); SetDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); SetLayout (flow); PayMethod.addItemListener (this); Adding (payList); Add (payMethod); Pamthip.editem ("credit card"); PayMethod.addItem ("check"); PayMethod.addItem ("cash"); (TotFees); } Public static zero main (string [] argument) {JFrame cframe = new DebugFourteen2 (); Cframe.setSize (350, 150); Cframe.setVisible (true); } Public Zero ItemState Changel (Object Extension List) {Object Source = list.getSource (); If (source == pay-meth) fee = pemthipant Sejeted Index (); FeePCT = fee [fee]; Output = feature + + + + + pctMsg; TotFees.setText (production); }}
No comments:
Post a Comment