Forums Register Login

Applet won't calculate

+Pie Number of slices to send: Send
I have an applet program here that allows the user to choose a movie then a number of tickets from a drop-down list. A check box should display for users to click so they can receive a discount for matinee movies. The user should be able to click a calculate price button to display the total cost and a clear button to clear each drop-down list and the check box. The program compiled but when I clicked the calculate button, it generated so many error codes like java.lang.nullPointerException and a lot more. I just wanted the program to work properly so please help me. Please refer to the code below:



The applet code:


Pardon me for the clumsy design because I didn't create a layout manager. I very much welcome tips and comments to further improve the code for this program. Thank you so much!
1
+Pie Number of slices to send: Send
For starters, string equality is checked using the "equals" method, not with the "==" operator.

Secondly, you can't access "presyoKo[i]" until that array has been created. So far, the code declares it, but doesn't create the actual array - for example, "double presyoKo[] = new double[15]" would allow you to store 15 values in it.

And yes - you should use proper layouts.
+Pie Number of slices to send: Send
Here's the actionPerformed method and itemStateChanged blocks of my program. There are two buttons and choice components in my program that's why I have both the actionPerformed and itemStateChanged methods. The program works fine but what method should I use with the matineeBox checkbox to disable it (not clickable) and it will only be active or can be checked once the user clicks the calculate button and the charge displays?


And could you please advise me how to get the value of the choice component (ticketsChoice) without creating a user-defined class. The user-defined class here is: catcher[i] = new Proj4exe2Class(ticketPrice);
+Pie Number of slices to send: Send
Please use Code Tags.
+Pie Number of slices to send: Send
That method is far too large and should be converted to several methods.
And when my army is complete, I will rule the world! But, for now, I'm going to be happy with this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 671 times.
Similar Threads
class is not abstract?
Two Classes and a Public Void!
Changing Labels on an Checkbox Group
calculating totals in an applet
why can't I get this?
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 02:04:39.