• Post Reply Bookmark Topic Watch Topic
  • New Topic

Creating tabs with for loop  RSS feed

 
Greenhorn
Posts: 5
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Im trying to add tabs to JTabbedPane with for loop. It works but I have naming question - how to assign new i value to each tab?


This works well:


This isn't:


Whats wrong here?

 
Sheriff
Posts: 4293
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you need "j" instead of "i".
 
W Lis
Greenhorn
Posts: 5
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Knute Snortum wrote:I think you need "j" instead of "i".

Thats it, but its only part of solution.
I modified it so now it looks like this:
for (int i = 1; i <= 10; i++) {
            tabsForm.add("Tab "+i, new Label("Tab "+i)); 
        }

I had to get rid of initializer. Now it works flawlesly. Thanks.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!