Taskbar icon with lwjgl?

不想你离开。 提交于 2019-12-06 05:54:35

问题


I want to add a taskbar icon for my running lwjgl process on Windows 7.

Display.setIcon changes successfully the icon in the topleft of the window, but not in the taskbar.

What do to?

My code, something like:

ArrayList byteBuffers = new ArrayList();
byteBuffers.add( ImageHelper.loadImageAsIconImage("stickmanicon32x32.png") );
byteBuffers.add( ImageHelper.loadImageAsIconImage("stickmanicon16x16.png") );
System.out.println( "taskbaricon result: " + Display.setIcon(byteBuffers.toArray(new ByteBuffer[]{})) );

I tried adding a 40x40 image too, but no change.


回答1:


This code worked just fine for me. No need of extra libs.

ByteBuffer[] list = new ByteBuffer[2];
list[0] = createBuffer(ImageIO.read(new File("src/Images/Tests/icon16.png")));
list[1] = createBuffer(ImageIO.read(new File("src/Images/Tests/icon32.png")));
Display.setIcon(list);



回答2:


You should have a look at J7Goodies a Java library that provides many Windows 7 features.




回答3:


This is what i found out after messing around after a few hours.

I used the slick-util lib.

Display.setIcon(new ByteBuffer[] {
                    new ImageIOImageData().imageToByteBuffer(ImageIO.read(new File("res/game/gameIcon.png")), false, false, null),
                    new ImageIOImageData().imageToByteBuffer(ImageIO.read(new File("res/game/gameIcon.png")), false, false, null)
                    });


来源:https://stackoverflow.com/questions/4791654/taskbar-icon-with-lwjgl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!