我已经声明了一个数组:
private javax.swing.JPanel[] panelArray = new javax.swing.JPanel[3];
我也有 3 个面板:panel0、panel1 和 panel2。我可以将这些面板添加到阵列中吗?IE
panelArray[0] = panel0;
panelArray[1] = panel1;
panelArray[2] = panel2;
然后像这样操作数组?
boolean[] myBools; .... then set them as true/false
for(int i=0; i<3; i++)
{
if(myBools[i])
panelArray[i].setVisible(true)
}
因为那对我不起作用