图标无法显示

小梁_unique 2009-11-29 11:05:42
各位高手帮帮忙:我把图标文件改成了GIF各式的了。放到了工程目录下,怎么就是无法显示出来。问题出在哪里?哪位大哥能简单的列举两行代码示范的话,小弟感激不尽。。。。。。。。。
...全文
70 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
小梁_unique 2009-12-01
  • 打赏
  • 举报
回复
自己写的,就是属于集成JlAbel
buqitianxie 2009-11-30
  • 打赏
  • 举报
回复
Block是什么类。集成Jlabel?
小梁_unique 2009-11-30
  • 打赏
  • 举报
回复
public class LayMines {
ImageIcon mineIcon;
public LayMines() {
// TODO Auto-generated constructor stub
mineIcon=new ImageIcon("WINMINE1.gif");
}
public void layMinesForBlock(Block block[][],int minecount){
int row=block.length;
//通过一位数组获取行
int coclum=block[0].length;
//通过二维获取列
LinkedList<Block> list =new LinkedList<Block>();
//用栈结构来存储数据
for (int i = 0; i < row; i++) {
for (int j = 0; j <coclum; j++) {
list.add(block[i][j]);

}

}
while (minecount>0) {
int size=list.size();
int random=(int)(Math.random()*size);
Block block1=list.get(random);
block1.setisMine(true);
block1.setName("雷");
block1.setimageIcon(mineIcon);
list.remove(random);
minecount--;

}
是静态图标啊,我就像这样写的。怎么无法显示?
不善^ 2009-11-29
  • 打赏
  • 举报
回复
动态的不知道能不能显示 我觉得不能
horizonlyhw 2009-11-29
  • 打赏
  • 举报
回复
不過 我感覺 不是所有的gif格式 都可以顯示
amdgaming 2009-11-29
  • 打赏
  • 举报
回复
你获取的方式 对吗??
比如你在你的 Test类中 用,那么可以这样
ImageIcon test = new ImageIcon(Test.class.getResourceAsStream("/com/test/test.gif"));

62,614

社区成员

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

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