Hi everyone How do you make a textfield read as an int? I know it has something to do with Integer.parseInt() but do not know how it works. I have six TextFields, named textField1, textField2, textField3 etc... and only 2 digits can be inserted.
TextField textField1 = new TextField(2); TextField textField2 = new TextField(2); etc... but how do I make int an int???
Is there a reason that all the ints must be stored in the same variable? Perhaps creating a separate variable to hold each result might be a good idea?
well each text field id going to insert the users lottery numbers.The user can insert 6 numbers. and then once this is done when pressed ok this will let the computer generate its own random numbers.
Rupinder Where in the code did you add the parseInt calls? Are in an event handler or in some other part of the code? Can you show the code where it is added - if it's a lot of code just show us a snippet and let us know where it falls in the whole thing.
Hi Rupinder I was just wondering, the way I understand this is the user must enter numbers into these TextFields and then click on the ok button, but why are you then adding action listener to each TextField ? if the code in actionperformed() should only be executed once the user presses the ok button this will never happen. because you have no action listener on the button , and from what I can see, it will execute for each key pressed in any of the Fields. [ August 27, 2002: Message edited by: Thomas Paul ]
Any Body can be paid to write good code, but brilliant code can only come from passion
SO how do I attempt to make the button work with textFields1,2,3,4,5 and 6. How do I make it like make the random generator work once button ok has been pressed. I need it to generate and activate the textfields 7, 8, 9 ,10 ,11 and 12.> So once ok is pressed it will automatically do this.
You want to add a listener to the button press and then process the text fields when the button is pressed. You don't need to listen for any events on the text fields.