错在哪?为什么显示不出图像来

freezhATsis 2009-03-26 08:29:45


//工具栏

JButton toolNewFile = new JButton(new ImageIcon("images/toolNewFile.jpg"));

JButton toolOpenFile = new JButton(new ImageIcon("images/toolOpenFile.jpg"));

JButton toolSaveFile = new JButton(new ImageIcon("images/toolSaveFile.jpg"));

JButton toolCopy = new JButton(new ImageIcon("images/toolCopy.jpg"));

JButton toolCut = new JButton(new ImageIcon("images/toolCut.jpg"));

JButton toolPaste = new JButton(new ImageIcon("images/toolPaste.jpg"));

JButton toolSelectAll = new JButton(new ImageIcon("images/toolSelectAll.jpg"));


图片在文件夹images中,文件夹与源文件同目录下!

...全文
62 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
Wbl314 2009-03-28
  • 打赏
  • 举报
回复
这种问题 把图片多移动几次
相关文件夹都移到了 正确了 记住 下次就对了
就晓得了
hoooooo 2009-03-28
  • 打赏
  • 举报
回复
这个问题我也遇到了,真是痛苦极了,试了很多方法,用这个比较有效

JButton toolNewFile = new JButton(new ImageIcon(getClass().getResource("images/toolSelectAll.jpg")));

试一下,应该就可以了

62,616

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧