Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
运行java代码可以在调试器中工作,但不能在运行中工作_Java_Frames - Fatal编程技术网

运行java代码可以在调试器中工作,但不能在运行中工作

运行java代码可以在调试器中工作,但不能在运行中工作,java,frames,Java,Frames,运行java代码可以在调试器中工作,但不能在运行中工作。在eclipse调试器中,它显示了我的jframes 然而,当我运行它时,我的框架不会出现任何东西 我相信我把我的听众搞砸了 private class ButtonHandler implements ActionListener{ JButton button; public void actionPerformed(ActionEvent event) { find(event.getSource()

运行java代码可以在调试器中工作,但不能在运行中工作。在eclipse调试器中,它显示了我的jframes

然而,当我运行它时,我的框架不会出现任何东西

我相信我把我的听众搞砸了

private class ButtonHandler implements ActionListener{
    JButton button;

    public void actionPerformed(ActionEvent event) {
        find(event.getSource());

        button = buttonHolder[indexK[kCount-1]][indexJ[jCount-1]];

        if((button.getIcon() == red && choice1 == 1) || (button.getIcon() == green && choice1 == 0)){
            JOptionPane.showMessageDialog(null, "You chose the wrong color!");
            return;
        }

        if(turn ==1){
            if(clicks != 1){
                if(button.getIcon() == red){
                    clicks++;
                    temp = button;
                }else if (button.getIcon() == green){
                    clicks++;
                    temp = button;
                }else{
                    kCount=0;
                    jCount=0;
                }
            }else{
                if((button.getIcon() == green) ||  (button.getIcon() == red)){
                    //do nothing
                }else if(temp.getIcon() == green && (grid[indexK[1]][indexJ[1]] == 2 || grid[indexK[1]][indexJ[1]] == 3 || grid[indexK[1]][indexJ[1]] == 4) && button.getIcon() != green && ((indexK[0]+1 ==indexK[1] && indexJ[0] == indexJ[1]) || (indexK[0] ==indexK[1] && indexJ[0]+1 == indexJ[1]) || (indexK[0] ==indexK[1] && indexJ[0]-1 == indexJ[1])) ){
                    temp.setIcon(null);
                    button.setIcon(green);
                    grid[indexK[1]][indexJ[1]] = 2;

                    if(indexK[0] == 0 || indexK[0]== 9){
                        grid[indexK[0]][indexJ[0]] = 4;
                    }else{
                        grid[indexK[0]][indexJ[0]] =3;
                    }
                    found = 2;

                }else if(temp.getIcon() == red && (grid[indexK[1]][indexJ[1]] == 1 || grid[indexK[1]][indexJ[1]] == 3 || grid[indexK[1]][indexJ[1]] == 5) && button.getIcon() != red && ((indexK[0]+1 ==indexK[1] && indexJ[0] == indexJ[1]) || (indexK[0] ==indexK[1] && indexJ[0]+1 == indexJ[1]) || (indexK[0]-1 ==indexK[1] && indexJ[0] == indexJ[1]))){
                    temp.setIcon(null);
                    button.setIcon(red);
                    grid[indexK[1]][indexJ[1]] = 1;

                    if(indexJ[0] == 0 || indexJ[0]== 9){
                        grid[indexK[0]][indexJ[0]] = 5;
                    }else{
                        grid[indexK[0]][indexJ[0]] =3;
                    }
                    found = 2;
                }

                clicks=0;
                kCount=0;
                jCount=0;
            }

        }
    }

}
}


如果你没有发现任何问题,你能想出一个原因来解释它为什么会出错吗?

首先,再次检查你是否在相同的模式下运行它。为小程序模式制作的程序与应用程序不同

如果这不起作用:

如果作为小程序运行: 检查您是否有init函数

如果作为应用程序运行: 检查您是否在运行配置中定义了一个主类。如果是,请确保在其中运行main()方法