首页 > 编程知识 正文

java图标的使用(java前端中的icon,用于ImageIcon的getResources()-Java)

时间:2023-05-06 01:31:02 阅读:124092 作者:4500

my very first question:

I ' vebeentryingtofigurethisoutforacoupleofdays,butigottothepointilostmypatience。

thefollowingaresomecodeandmyprojectstructure。

question : howcanigetgetresources () toworkineclipseandafterbeingimportedtojar?

Thanks for the help。

公共枚举icons {

XXX (src/resoruces/icons/XYZ.png );

私有图像输入;

icons (字符串路径) {

try {

//willfailmiserablyineclipseandafterexportingtojar

icon=newimageicon(imageurl;

}catch(exceptione ) {

//workslikeacharineclipseandaftercreatingthejarfile

//withthefilesinthesamedirectory

icon=new image icon (路径;

}

}

ifthepngfileshavebeenpackagedintothejarinthesamelocationsastheyareintheoriginalsrcdirectorythen

XXX(resources/icons/XYZ.png );

Should产品the right result。

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。