Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.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_Linked List_Point - Fatal编程技术网

Java 如何将图像添加到链接列表中的元素

Java 如何将图像添加到链接列表中的元素,java,image,linked-list,point,Java,Image,Linked List,Point,我正在制作蛇的游戏。我已经将蛇定义为一个链表,它将个体保存在一个元素中。我想将每个位设置为具有我创建的尺寸(20,20)和jpeg格式的图像。我已经将图像放置到src foldr中,我在其中创建了一个资源文件夹,这是保存图像的地方 这是我用来设置此图像的方法。我不确定如何在这个范围内设置图像。将调用该方法来绘制蛇 //This is a method used to set the image for the snake bits. public void imgSnake() {

我正在制作蛇的游戏。我已经将蛇定义为一个链表,它将个体保存在一个元素中。我想将每个位设置为具有我创建的尺寸(20,20)和jpeg格式的图像。我已经将图像放置到src foldr中,我在其中创建了一个资源文件夹,这是保存图像的地方

这是我用来设置此图像的方法。我不确定如何在这个范围内设置图像。将调用该方法来绘制蛇

//This is a method used to set the image for the snake bits.
    public void imgSnake() {
        //A for loop which will assign every point on the snake linked list to have this image.
        for (Point p : snake) {
             //This is where I need to set the image
        }

为什么需要设置图像?画吧!有没有可能画一幅边框宽度为2像素的图像?这个想法是要有一个图像,它有一个黑色的轮廓填充绿色来代表位。这是一款为小学生设计的游戏,试图让它尽可能有趣。请看
JComponent.paint
方法。