java.lang.ArrayIndexOutOfBoundsException:3 for循环

时间:2019-05-24 23:09:17

标签: java

你好,当我尝试编译以下程序时,Cards [r] [c] = new JButton(flipped); ..该循环应该创建一个二维jbutton,但是我无法找到它出来。任何帮助将不胜感激

public class EasyMode extends JPanel{
int x=3,y=4;
int r,c;
private JPanel jpEasy;
private JButton[][] Cards;
private ImageIcon flipped,img1,img2,img3,img4,img5,img6;
public EasyMode(){

    jpEasy=new JPanel(new GridLayout(x,y));
    flipped=new ImageIcon("flipped.png");
    Cards=new JButton[y][x];

    for(int r=0;r<y ;r++){
        for(int c=0;c<=x;c++){
             Cards[r][c] = new JButton(flipped);

        }
    }

0 个答案:

没有答案