windows 带有 lwjgl 的任务栏图标?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4791654/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 16:03:57  来源:igfitidea点击:

Taskbar icon with lwjgl?

javawindowswindows-7taskbarlwjgl

提问by Hugh Perkins

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

我想为我在 Windows 7 上运行的 lwjgl 进程添加一个任务栏图标。

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

Display.setIcon 成功更改了窗口左上角的图标,但不在任务栏中。

What do to?

做什么?

My code, something like:

我的代码,类似于:

ArrayList<ByteBuffer> byteBuffers = new ArrayList<ByteBuffer>();
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.

我也尝试添加 40x40 图像,但没有变化。

采纳答案by MxR

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);

回答by Tyler Bucher

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

这是我在几个小时后搞砸后发现的。

I used the slick-util lib.

我使用了 slick-util 库。

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)
                    });

回答by torn

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

您应该查看J7Goodies一个提供许多 Windows 7 功能的 Java 库。