![]() |
Java Error Messages
1 Attachment(s)
I received an error. I have posted a pic of the errors that I am receiving. Can someone please have a look at this and show me what I am doing wrong? Here is the code and then the pic.
:
import javax.swing.*; |
Re: Java Error Messages
ExitButtonHandler and main() are defined outside of your class body. Check your braces. You also have a missing brace on this if() block and no block at all on the (resultb < 8) statement
:
if (resultb > 8):
if (resultb > 8){ |
Re: Java Error Messages
1 Attachment(s)
Ok, I fixed my brackets, and also had to give the event the ev name instead of"e" because it was already being used. I imported the import java.io.* statement and added the class extends section of the code.
I still have an error, when I enter the numbers in. I receive the catch message, and I shouldn't because I am entering a number. Whats wrong? I attached a picture. I am happy though that I can at least see my program now. :) Have a look please. :
import javax.swing.*;attached picture |
Re: Java Error Messages
This section is going to throw your exception if resultc is not equal to 10. I doubt that is the intent
:
if (resultc == 10){ |
Re: Java Error Messages
Quote:
This isn't my intent. What I am trying to do is perform the calculations based on my if statements, and if anything else is entered like a ., a letter, or anything besides a number, it should be caught and display the sentence in the outputbox "Illegal entry, please enter a number" Any ideas? |
Re: Java Error Messages
instead of using all if statements you use elseif?
and then leave your else statement at the end. Chris |
Re: Java Error Messages
I figured it out.
I needed to use the NumberFormatException and delete the extends section and also parse within the try statement to have something to try with. Here is what I did. :
try |
Re: Java Error Messages
Your try-catch on NumberFormatException really only needs to be around this portion
:
resulta = Integer.parseInt(resultATF.getText()); |
| All times are GMT -5. The time now is 12:46 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC