Results 1 to 5 of 5
Thread: Exception catch
- 08-08-2011, 06:30 PM #1
Member
- Join Date
- Oct 2010
- Posts
- 33
- Rep Power
- 0
- 08-08-2011, 06:40 PM #2
There should not be any exception when a button is pressed.What kind of exception am I supposed to catch when I press a jButton
I assume that the field contains a String.take an integer from a field
There could be an exception when you try to convert the String to an int if the contents is not numeric.
Look at the API doc for method you are using to convert the String to an int. The doc should list what exceptions can be thrown for that method.
- 08-08-2011, 06:56 PM #3
Member
- Join Date
- Oct 2010
- Posts
- 33
- Rep Power
- 0
Ok, I'll do that, but I still didn't get what exception I am supposed to catch, when I try to pass a string from an empty field(the 1st question). Let me put it to examples, cause clearly many people cannot understand what my problem is.
If the field contains nothing, no strings, no integers, no chars, nothing and I press the button(call a method), my program freezes, since its expecting some kind of characters in that field(String, int,...), but it doesn't find any. The question was: How should I handle that, without the program freezing-.gif)
- 08-08-2011, 07:01 PM #4
There should be no exception when getting an empty String from a text field. The exception would occur in a method that tries to convert that String.what exception I am supposed to catch, when I try to pass a string from an empty field(the 1st question)
Or is your question: How do I throw my own exception when the program detects that the use has entered invalid data?
Please explain. Are there any error messages? Please copy and paste the full text here.my program freezes,
Does the program go into an infinite loop somewhere?
Add lots of println statements to show where the execution flow goes and how the values of variables change.
- 08-09-2011, 09:41 AM #5
Similar Threads
-
try catch exception
By soxfan714 in forum New To JavaReplies: 3Last Post: 05-05-2011, 11:11 AM -
try, catch, exception error
By Asvin in forum New To JavaReplies: 5Last Post: 04-11-2011, 10:12 PM -
Catch exception, return to while loop
By ChicagoAve in forum New To JavaReplies: 3Last Post: 02-20-2011, 06:44 PM -
catch the number format exception, where to place try
By aborgeld in forum New To JavaReplies: 7Last Post: 12-30-2010, 01:42 PM -
Why can't I catch an exception?
By glhansen in forum New To JavaReplies: 5Last Post: 03-17-2009, 06:48 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks