开发者

How to make number of panels = number of iterations in for loop

开发者 https://www.devze.com 2023-03-05 18:07 出处:网络
How do I make number of panels equal to number of iterations in for loop in Java? E.g 4 iterations will have 4 panels开发者_高级运维 with different name.

How do I make number of panels equal to number of iterations in for loop in Java?

E.g

4 iterations will have 4 panels开发者_高级运维 with different name.

Thanks


-_- is that what you want?

List<JPanel> panels = new ArrayList<JPanel>();
for (int i = 0; i < 4; i++) {
    JPanel p = new JPanel();
    p.setName("1337 PANEL No.: " +String.valueOf(i));
    panels.add(p);
}
for (JPanel p : panels) {
    System.out.println(p.getName());
}


I'll play: are you thinking of JTabbedPane?

0

精彩评论

暂无评论...
验证码 换一张
取 消