Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/311.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_Image_Loops - Fatal编程技术网

Java通过循环读取图像

Java通过循环读取图像,java,image,loops,Java,Image,Loops,我正在阅读两张完全相同名称但编号为1-6的图像,因此我使用和数组来读取图像,例如AstroWalkLeft1、AstroWalkLeft2到arimgAstroWalkleft[]。这就是我所拥有的: public void GetImages() { imgMonster = new ImageIcon("Assets\\MonsterSingle.png").getImage(); for (int i = 1; i <= nASTROIMGMAX; i++) {

我正在阅读两张完全相同名称但编号为1-6的图像,因此我使用和数组来读取图像,例如AstroWalkLeft1、AstroWalkLeft2到arimgAstroWalkleft[]。这就是我所拥有的:

public void GetImages() {
    imgMonster = new ImageIcon("Assets\\MonsterSingle.png").getImage();
    for (int i = 1; i <= nASTROIMGMAX; i++) {
        arimgAstroWalkLeft[i] = new ImageIcon("Assets\\AstroWalkLeft" + i + ".png").getImage();
        arimgAstroWalkRight[i] = new ImageIcon("Assets\\AstroWalkRight" + i + ".png").getImage();
    }
    imgAstroStandLeft = new ImageIcon("Assets\\AstroStandLeft.png").getImage();
    imgAstroStandRight = new ImageIcon("Assets\\AstroStandRight.png").getImage();
    imgBackground1 = new ImageIcon("Assets\\Hallway.png").getImage();
    imgBackground2 = new ImageIcon("Assets\\Observation Room.png").getImage();
}
public void GetImages(){
imgMonster=newimageicon(“Assets\\MonsterSingle.png”).getImage();

对于(int i=1;我可以给你一些你想要实现的例子吗?我想你必须重新表述一下你的问题:你到底希望这段代码做什么,而它现在没有做?另外,数组是基于0的。最好使用一个列表…我的问题是NetBeans不喜欢“AstroWalkLeft”+i+“.png”因此它不会在我的图像中读取。1)为了更快地获得更好的帮助,请发布一个。2)获取图像的一种方法例如,热链接到在中看到的图像。