查看最后一行代码,这是我特别想将 JPanel 数组添加到容器的地方。非常感谢伙计们或加尔斯!
代码:
private JFrame b = new JFrame("Lotus");
private JLabel currentP = new JLabel();
private int currentS;
private Container pieces = new Container();
private JButton exitt = new JButton("EXIT");
private ImageIcon B1=new ImageIcon("C:\\Users\\Brusty\\Downloads\\p1.jpg");
private ImageIcon B2=new ImageIcon("C:\\Users\\Brusty\\Downloads\\p2.jpg");
LinkedList<Stack<Integer>> spotList = new LinkedList<Stack<Integer>>();
//Creation of Gamepiece labels
public void Labels(){
JLabel[] labelsP1 = new JLabel[10];
JLabel[] labelsP2 = new JLabel[10];
for(int i = 0 ; i < labelsP1.length ; i++){
labelsP1[i] = new JLabel(B1);
for(int j = 0 ; j < labelsP2.length ; j++){
labelsP2[j] = new JLabel(B2);
}
Container c = b.getContentPane();
c.setLayout(new GridLayout(13,3));
c.add(pieces);
pieces.add(labelsP1);