Adding JPanels through a loop
问题 Made it work! Thank you guys! The code follows. I used BoxLayout since I thought it'd be ideal for stacking questions one on top of the other, but now I got issues with the layout... When I stack several questions the question panels start overlapping. Any thoughts? panels1 = new MultipleChoice[5]; setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); for(int i=0; i<4; i++){ panels1[i]= new MultipleChoice(); panels1[i].setAlignmentX(CENTER_ALIGNMENT); add(panels1[i]); } setVisible(true); I'm