View Single Post
  #11 (permalink)  
Old 09-13-2008, 01:40 PM
Grom Grom is offline
Member
 
Join Date: Aug 2008
Posts: 20
Grom is on a distinguished road
Hello Java Forum,

Ola Norm, I am more of weekend programmer, since I have job, duties,... but no kids yet, so I can use weekends for 'programming'

I have made my application with Visual C#, please take a look at www beezgetz.com/Tour.aspx . Now I want to translate it to java, so Mac users can use it.

Here is the picture of my java application, where jTextField checks each typed 'character' of string (as it is typed) if it is really a number (double), and if it is not, to clear the jTextField.
http ://shrani.si/f/2b/VV/d3SvkCl/application.png


Here is code
Code:
private void DoubleTextFieldCaretUpdate(javax.swing.event.CaretEvent evt) { try { String number = DoubleTextField.getText(); // I get string from TextField DecimalSeparator.StringToDouble(number); // I run it through DecimalSeparatot Class to make it double, or catch (Exception e). DoubleLabel.setText(String.valueOf(number) + " double"); //I run some action } catch (Exception e) { DoubleTextField.setText(""); } }

Here is called Class:

Code:
public class DecimalSeparator { public static double StringToDouble(String stringNum) { String decimalCharacter = "."; stringNum = stringNum.replace(".", decimalCharacter); stringNum = stringNum.replace(",", decimalCharacter); return Double.parseDouble(stringNum); } }



I am getting familiar with api, but I need some time to make it search the 'right stuff'


Kind regards, Grom
Reply With Quote