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?
精彩评论