This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I want to convert a string from a JTextField gotten using field.getText(); to a type double. I tried using valueOf, but then I can't use the + operator or any other math operand. I am making a calculator program in Swing.
How about: double dbl = (new Double(field.getText())).doubleValue(); You'll probably want to wrap it in a try/catch block in case the user puts in something invalid. You could also use regular expressions to do some validation and warn the user if it's bad.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: Convertinf string to double from JTextField