Shop OBEX P1 Docs P2 Docs Learn Events
Button creation — Parallax Forums

Button creation

WaldoDTDWaldoDTD Posts: 142
edited 2006-07-28 06:55 in General Discussion
Hey,
I am trying to create a GUI for my robot applications and I was wondering if there is a way to create a series of buttons based off of the size of an arraylist? It would be something like

while(index != arraylist.getSize()){
JButton J1 = JButton("");
}

I need to know as while the loop completes is it possible to increment the number to J1, J2, J3 etc....

I know this is for Javelin stamp but I have no idea where to post this.-signol01

Comments

  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-07-28 06:55
    You can't create named variables that way.
    Perhaps this:

    int size;
    JButton[noparse]/noparse jb = new JButton[noparse][[/noparse]size]; //create array of Button
    for (i=0; i<size; i++) { //initialize each entry
    · jb[noparse][[/noparse]i] = new JButton("");
    }


    regards peter
Sign In or Register to comment.