Original Post
hello guys! Im writing some code to handle a gazillion buttons from my swing gui. so... i set the "ActionCommand" property in each of the buttons in a way that i can see right away which button was pressed. so far so good. I get strings of the form: "qxby" where x can go from 1 to as many "questions" there are and y can be only 1, 2 or 3. q refers to "question". every "question" is composed of 3 radio buttons (yes, no, maybe). and b refers to the radiobuttons, as answers for the questions... so if you click on "maybe" radio button that goes with the "question number 28" the string will be: "q28b3" i want to store all answers in a list, making the index in the list match the number of the question. ok? so answer[5] is the answer for the 6th question, and i can get its value by doing: answer.getElementAt(5). so far so good... its just im having trouble indexing right. why? cuz there must be as many positions in the list as questions, but i have a lot more radiobuttons, for every question has 3 radiobuttons. so every time a radiobutton is clicked, i need to store an answer. but the index of the answer list aint the same as the radiobutton's index. are you following? i also have a "commandslist" which i use to index the radiobuttons. the commands list goes as: 0 q1b1 1 q1b2 2 q1b3 3 q2b1 4 q2b2 . . . and the answer list would go like: 0 Y --> answer for first question, meaning Yes, or the radiobutton b1 1 Y 3 N 4 M . . . so i cant use the same var to index both lists, as one has far more elements than the other. i guess you get the idea. so, to make sure i get the proper index, and store the answer in the right position in the answer list, I want to read the number of the question from the ActionCommand string. so, inside the ActionPerformed method, i can get my "event.getActionCommand()" and it will read something like "q29b2" so... whats left to do: strip the "garbage" from that string, making it "29" so i can properly convert it to a int. like: removed --> q / 29 / b2<-- removed how would my event.getActionCommand().subString(xxxxx) statement go? i figure i need 2 of them? i suck on string manipulation and if there are better ways to do it.. be my guest :D