开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜