Results 1 to 11 of 11
Thread: try catch in swing.
- 09-03-2009, 02:32 PM #1
Member
- Join Date
- Nov 2008
- Posts
- 71
- Rep Power
- 0
- 09-03-2009, 02:38 PM #2
It's the same as in AWT or any other piece of code. What's the problem? What part of the tutorials didn't you understand?
- 09-03-2009, 03:22 PM #3
try { //put ur code that is supposed to thrw exception }
catch (Exception e) //u can specify name of exception in place of "Exception" if u know, <or u can see wen u run without try n catch>
{[
System.out.println("exception"+e);
}
- 09-03-2009, 03:23 PM #4
- 09-03-2009, 07:34 PM #5
yeah man .. correct ..but for the beginers sake ... can start this way ..
but its always good to go 4 STACK Trace..
- 09-03-2009, 08:00 PM #6
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
- 09-04-2009, 02:51 PM #7
Member
- Join Date
- Nov 2008
- Posts
- 71
- Rep Power
- 0
hi to everyone.. tnx... my problem is when i put a string in the jtextfield still my System.out.println("error") didnt show ....this is my code:
public static void main(String args[]) {
try{
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new OddEven().setVisible(true);
}
});
}
catch(Exception e){
System.out.println("error");
}
i am using the netbeans editor:cool:
- 09-04-2009, 02:54 PM #8
Member
- Join Date
- Nov 2008
- Posts
- 71
- Rep Power
- 0
this is my error... i already code the try catch but still the same output... the error message didnt show when i put a string in the textfield
:cool:
- 09-04-2009, 02:57 PM #9
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
If you want there to be an error printed to the console when someone enters text into a textfield then your code is way off what you want to do. Where are you checking the text entered on the textfield?
You would need to register an appropriate listener on the textfield and do the printing in the listener's handler method.
- 09-05-2009, 03:43 AM #10
Member
- Join Date
- Nov 2008
- Posts
- 71
- Rep Power
- 0
you mean , i have to code for the handler listener for textfield??
:cool:
- 09-05-2009, 05:41 AM #11
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
Similar Threads
-
how to catch two exceptions in one catch()?
By arnab321 in forum New To JavaReplies: 1Last Post: 11-06-2008, 10:54 AM -
try catch...
By MarkWilson in forum New To JavaReplies: 8Last Post: 06-27-2008, 05:39 PM -
Try Catch
By Renegade85 in forum New To JavaReplies: 4Last Post: 12-03-2007, 04:10 PM -
when to use try...catch
By javaplus in forum New To JavaReplies: 2Last Post: 11-18-2007, 08:52 PM -
Use try and catch
By zoe in forum New To JavaReplies: 2Last Post: 07-25-2007, 07:50 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks