Click to See Complete Forum and Search --> : help with something


keko2005
11-09-2005, 12:53 PM
hey guys, im not sure how to explain this, so ill do the best i can.

A user will be prompted to input the number of, lets say columns. the user then enters 3. then a for loop will distribute 3 rows of 5 text fields.
so it will look something like this:

(* = text fields )
r1 = * * * * *
r2 = * * * * *
r3 = * * * * *

when the user finishes filling out the fileds, i then need to turn each row into one string. so all the fields in row 1, will become one string. String str1 = * + * + * + * + *;
same goes for the other rows. now when each row is converted to a string i need it to be stored in array. i can take care of the array part. its turing each one into a string that troubles me, because i dont know how to identify each field in the row. can someone help me out? thanks

Khalid Ali
11-09-2005, 01:00 PM
are u talking about JavaScript?

keko2005
11-09-2005, 01:01 PM
no im not, im am designing a Java app. i know this isnt a java script forum

Khalid Ali
11-09-2005, 01:03 PM
good..actually ur question is not clear enuf... when u say text fields are you talking about a Java swing(GUI) app then

keko2005
11-09-2005, 01:08 PM
yea, JTextFields, 5 of them. have you ever used phpMyAdmin? if so, when u create a table with a specified number of Columns, ur taken to a page like the one i described before, where you can fill out each JTextField for each row

keko2005
11-09-2005, 02:24 PM
hey Khalid Ali, i figured a way to do it, but let mek now if you have something better. i used a mult dim array like so:


public static void test(int num){
int l = 0;
String array[][] = new String[num][5];
for(int i =0; i<num; i++){
array[i][l] = JOptionPane.showInputDialog("1") + " " + JOptionPane.showInputDialog("2");
System.out.println((i + 1) + " = " + array[i][l]);
}
}

also. i used JOPanes as you can see, if i used JTextFields to get the input, will it have the same effect?

Oak
11-10-2005, 04:12 AM
Yes.

keko2005
11-10-2005, 07:54 AM
it does, what i did was looped out the JTextfields, and used a multi dimension array to store the results for each row. then created another loop to store the text results from the previous array :
arrayResult[j][i] = arrayJTF[j][i].getText() ;
thanks for the help guys.