theapache64
08/06/2021, 5:41 PMicon
property not working 🧵fun main(args: Array<String>) = application(
) {
Window(
onCloseRequest = ::exitApplication,
icon = painterResource("drawables/launcher_icons/linux.png")
) {
}
}
192x192
. but am getting below default java icon. Is there anything else i need to do to make it work? In the deprecated Window
API it was working fine with the same image.Igor Demin
08/06/2021, 6:21 PMbuild.gradle
(for native distribution) or via global function:
Taskbar.getTaskbar().iconImage
But I don't recommend to use it, as the icon in the taskbar will be changed not immediately, but after some time (1-2 sec).
We covered that in tutorials:
Note that to change the icon on the taskbar on some OS (macOs), you should change icon in build.gradleAnd in JavaDoc:
@param icon Icon in the titlebar of the window (for platforms which support this)
Taskbar.getTaskbar().iconImage
in runtime automatically (as in AppWindow) 🤔
Will setting icon in build.gradle be enough for you, or it would be better to set icon in Window, only to not see the default icon every time you debug your application?theapache64
08/06/2021, 6:56 PMmacOS {
iconFile.set(iconsRoot.resolve("launcher_icons/macos.icns"))
}
do you mean this? (or is this changed in new APIs) I already have that in place.Taskbar#iconImage
it works. but as a developer, I expect to work this via the icon
param (Window
API)Igor Demin
08/06/2021, 7:28 PMBy saying “setting icon in build.gradle”Yes, but this will work only for native distribution. For
./gradlew run
you can set it via:
application {
...
jvmArgs("-Xdock:icon=src/jvmMain/resources/ic_launcher.png")
It is not obvious, so I think, we should make it a default.
expect to work this via theThere is another problem - if you set icon for Window not inparamicon
icns
format, then the icon will be changed in 1-2 seconds after you run the application. By “changed” I mean the quality of icon will be changed, if you use something like png (icns have different resolutions, so it scales better)theapache64
08/06/2021, 7:30 PMIgor Demin
08/06/2021, 7:34 PMtheapache64
08/06/2021, 7:35 PMjava.lang.UnsupportedOperationException: The ICON_IMAGE feature is not supported on the current platform!
at java.awt.Taskbar.checkFeatureSupport(Unknown:-1)
at java.awt.Taskbar.setIconImage(Unknown:-1)
This is happening when I call
Taskbar.getTaskbar().iconImage
in Windows 10.
Any idea why its crashing? 🤔Igor Demin
09/12/2021, 9:07 AMicon
parameter in Window).
If you really want to set the taskbar icon for macOs in Runtime, you should check Taskbar.getTaskbar().isSupported(Taskbar.Feature.ICON_IMAGE)
But the recommendation for Compose is still the same - not to use Taskbar.getTaskbar().iconImage
and use icon
in build.gradle. We will add -Xdock:icon
by default in the future, so the icon will also be working in "debug" mode. Until then, you can add it yourself via jvmArgs
.theapache64
09/12/2021, 9:33 AM