gpt4 book ai didi

java - 我的应用程序(Java)做错了什么?

转载 作者:行者123 更新时间:2023-11-30 03:02:17 28 4
gpt4 key购买 nike

我正在尝试制作一个游戏,并且正在使用我找到的图 block 集(png)。我希望能够将图像分解为多个部分并将它们放置在 jframe 中的特定位置以显示运动。但首先我将如何开始导入图像。我所做的所有尝试都失败了,导入时图像变成文本文件。请帮忙解决这个问题,我该如何切割和排列瓷砖?

Picture Link here

Exception in thread "main" java.lang.IllegalArgumentException: input == null!
at javax.imageio.ImageIO.read(Unknown Source)
at World.Display.<init>(Display.java:15)
at Main

.main(Main.java:15)

import java.io.IOException;

public class Main {


public static void main(String[] args) throws IOException {
World.Display l = new World.Display();

}

}



package World;

import java.awt.GridLayout;
import java.awt.image.BufferedImage;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;

public class Display {

public Display() throws IOException{
BufferedImage img=ImageIO.read(getClass().getResource("assets/tilesetbackground.png/"));
ImageIcon icon=new ImageIcon(img);
JFrame frame=new JFrame();
frame.setTitle("Another RPG Version: "+Config.Global.Version);
frame.setLayout(new GridLayout(1024,768));
frame.setSize(1024,768);
JLabel lbl=new JLabel();
lbl.setIcon(icon);
frame.add(lbl);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

}

最佳答案

我确信字符串的正确格式应该从/开始

我在本地查了一下。请看一下图片

enter image description here

关于java - 我的应用程序(Java)做错了什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35659511/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com