Wednesday 15 July 2015

java - JTextField to int[] array? -


I am working on the graphic user interface for my application which I am making. Basically it is JTextField that the user has an integer, for example,

25, 50, 80, 90

Now, I have another class that receives those values And put them in a full array.

> I have tried the following.

  GUIV = drop Theseextext.getText (). the division (",");   

And in the second category, I leave the string, but I do not know how to get the value for each.

Finally I'm just trying to find something like this

  int [] vD = {textfieldvaluessplitbycommahere};   

Still new to Java is quite new but it's crazy to me.

  private JTextField txtValues ​​= new JTextField ("25, 50, 80, 90" ); // Strike the whitespace using regex, because they are to throw errors / when string values ​​= txtValues.getText (). All ("\\ s", ""); // Get the combined value of the text field and use the comma as the separator // Value will be given as string array Private string [] strValues ​​= values.split (","); // Early Sir Array Private int [] intValues ​​= new int [strValues.length ()]; // Convert each string value to integer value and for it integer array (int i = 0; i    

No comments:

Post a Comment