hey folks I'm having a problem with the Float.parseFloat(String s) method.
This sample Applet is fairly simple: the user enters some (float)value in the textfield, and that String then gets converted to a float. After that, the square of the float is shown in the label. For some reason I haven't found yet, the Applet doesn't react at all when the button is pressed. If i replace the Float.parseFloat with the parseInt argument, it works fine (except for the fact that the user has to enter integers - I know that I forgot to put all that in a try-catch method...let's just assume the user enters number values). Furthermore, I'm looking for a way to replace a char within a string with a new char ("," with "."). I tried the string.replace(oldchar, newchar) method, but it doesnt work. I was planning on putting that method in the KeyListener-method keyPressed or in the TextListener-method textValueChanged.Would be very nice, if you could tell me a better way to do it (if there is a better way...=). Thanks in advance, Soenke (edited by Cindy to format code)
[This message has been edited by Cindy Glass (edited November 08, 2001).]
The code works fine when I cut & paste and compile it. I entered 2.5 and clicked the button, 6.25 came in the label. I entered 10.0 and I got 100.0. Are you using the appletviewer or a browser to test it (just curious)? ------------------ WebNelly.com Java/XML Web Development Check it out! http://www.webnelly.com [This message has been edited by Kris Nelson (edited November 08, 2001).]
WebNelly.com<br />Java/XML Web Development<br />Check it out!<br /><a href="http://www.webnelly.com" target="_blank" rel="nofollow">http://www.webnelly.com</a>
Joined: Oct 21, 2001
I forgot to mention that I'm trying to get it to work on my IE5. So, I didn't mention that it worked fine in the appletviewer. BUT: hey, I found the error/ source of my problem - parseFloat is not supported by IE5, because it came out with JDK 1.2. Thanks to all those who would have helped me =)