将图像导入IntelliJ Java项目 [英] import images into an intelliJ Java project

查看:109
本文介绍了将图像导入IntelliJ Java项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个需要使用多个图像的Java项目。我在ubuntu linux上因此我在src目录中有一个images文件夹。到目前为止这么好但尝试我似乎无法找到一种方法来加载或导入图像文件到该图像文件夹。 (我希望能够简单地使用loadImage(images / imageToLoad.png);)

I am working on a Java project that requires the use of several images. I'm on ubuntu linux So I have an images folder inside my src directory. So far so good but try as I might I can't seem to find a way to load or import image files into that images folder. ( I want to be able to simply go something like loadImage("images/imageToLoad.png"); )

我试图拖放。我知道我当然可以离开程序并使用linux文件系统来传输图像,但这很痛苦并且无法实现IDE的目的。

I have tried to just drag and drop. I know that I could of course leave the program and use the linux filesystem to transfer the images but that's a pain and defeats the purpose of an IDE.

推荐答案

您必须在IntelliJ IDEA之外的文件管理器中执行此操作。要确保应用程序类路径中的图像可用,请选中设置 | 编译器 | 资源模式 .png 扩展名需要在那里列出。

You will have to do it in a file manager, outside of IntelliJ IDEA. To ensure that images are available in the application classpath check Settings | Compiler | Resource Patterns, .png extension needs to be listed there.

这篇关于将图像导入IntelliJ Java项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆