The Artima Developer Community
Sponsored Link

Java Answers Forum
create many variably named components?

1 reply on 1 page. Most recent reply: Jun 30, 2003 4:20 PM by zenykx

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Jakob Brøgger

Posts: 1
Nickname: whoosh
Registered: Jun, 2003

create many variably named components? Posted: Jun 29, 2003 7:32 AM
Reply to this message Reply
Advertisement
Hi

Is there a way where you can create say 'i' buttons with the name 'i' in a loop, in java?

something like

for(int i = 0; i <= 10;i++)
{
button &i = new button();
}

(this should produce 10 buttons named from 0 to 10, if it worked)


zenykx

Posts: 69
Nickname: zenykx
Registered: May, 2003

Re: create many variably named components? Posted: Jun 30, 2003 4:20 PM
Reply to this message Reply

JButton[] buttonArray = new JButton[];
for (int i=0;i<10;i++) {
buttonArray[i] = new JButton(""+i);
}


..but i think you can rtfm!

Flat View: This topic has 1 reply on 1 page
Topic: cannot start j2ee Previous Topic   Next Topic Topic: tricky problem with a code

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use