Results 1 to 2 of 2
- 05-20-2007, 11:15 AM #1
Member
- Join Date
- May 2007
- Posts
- 2
- Rep Power
- 0
- 05-20-2007, 11:19 AM #2levent Guest
Double has parseDouble method which tries to parse a String as a Double. You need to put it inside a try-catch block since it throws NumberFormatException.
You can write logic inside catch since it is called if the value is not a valid double!
Here is an example code:
Java Code:double value; try { // String textValue = the string from your JTextField value = Double.parseDouble(textValue); // if the code gets to here, it was recognizable as a double } catch(NumberFormatException e) { // if the code gets to here, it was NOT recognizable as a double }
Similar Threads
-
How to determine CPU usage using Java?????
By JavaEmpires in forum New To JavaReplies: 5Last Post: 03-16-2011, 04:49 AM -
how to focus to another JTextfield?
By birdofprey in forum AWT / SwingReplies: 2Last Post: 04-09-2008, 01:08 PM -
How to determine all the IP addresses of machines on local LAN??
By JavaEmpires in forum NetworkingReplies: 3Last Post: 01-19-2008, 06:05 AM -
how to determine the primary key
By osval in forum JDBCReplies: 1Last Post: 08-07-2007, 02:31 AM -
help with JTextfield
By gary in forum New To JavaReplies: 4Last Post: 07-11-2007, 01:58 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks