https://kotlinlang.org logo
Title
m

Mitchell Syer

08/22/2021, 7:27 PM
Hello, I am running into a issue with setting a icon for my window, I believe its because of a incompatibility with the Swing Laf library I use called DarkLaf. I am wondering if this needs to be fixed on the Compose side or the DarkLaf side. There is a exception when window tries to open, I have added it to the thread.
:thread-please: 1
Adding stack trace to thread instead of the message
15:24:18.520 [AWT-EventQueue-0 @coroutine#23] ERROR/UncaughtException: Uncaught exception in thread [AWT-EventQueue-0 @coroutine#23@40]
java.lang.UnsupportedOperationException: getSource() not supported
	at androidx.compose.ui.graphics.PainterImage.getSource(DesktopImageConverters.desktop.kt:137) ~[ui-graphics-desktop-1.0.0-alpha4-build315.jar:?]
	at java.awt.Image.getScaledInstance(Image.java:177) ~[?:?]
	at com.github.weisj.darklaf.platform.windows.ui.WindowsTitlePane.updateSystemIcon(WindowsTitlePane.java:657) ~[darklaf-windows-2.7.2.jar:2.7.2]
	at com.github.weisj.darklaf.platform.windows.ui.WindowsTitlePane.install(WindowsTitlePane.java:260) ~[darklaf-windows-2.7.2.jar:2.7.2]
	at com.github.weisj.darklaf.platform.decorations.CustomTitlePane.addNotify(CustomTitlePane.java:40) ~[darklaf-platform-base-2.7.2.jar:2.7.2]
	at java.awt.Container.addNotify(Container.java:2800) ~[?:?]
	at javax.swing.JComponent.addNotify(JComponent.java:4783) ~[?:?]
	at java.awt.Container.addNotify(Container.java:2800) ~[?:?]
	at javax.swing.JComponent.addNotify(JComponent.java:4783) ~[?:?]
	at javax.swing.JRootPane.addNotify(JRootPane.java:729) ~[?:?]
	at java.awt.Container.addNotify(Container.java:2800) ~[?:?]
	at java.awt.Window.addNotify(Window.java:783) ~[?:?]
	at java.awt.Frame.addNotify(Frame.java:490) ~[?:?]
	at java.awt.Window.show(Window.java:1045) ~[?:?]
	at java.awt.Component.show(Component.java:1717) ~[?:?]
	at java.awt.Component.setVisible(Component.java:1664) ~[?:?]
	at java.awt.Window.setVisible(Window.java:1028) ~[?:?]
	at androidx.compose.ui.window.AwtWindow_desktopKt$AwtWindow$4$1.invokeSuspend(AwtWindow.desktop.kt:122) ~[ui-desktop-1.0.0-alpha4-build315.jar:?]
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) ~[kotlin-stdlib-1.5.21.jar:1.5.21-release-314 (1.5.21)]
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) ~[kotlinx-coroutines-core-jvm-1.5.1.jar:?]
	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:316) ~[?:?]
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:770) ~[?:?]
	at java.awt.EventQueue$4.run(EventQueue.java:721) ~[?:?]
	at java.awt.EventQueue$4.run(EventQueue.java:715) ~[?:?]
	at java.security.AccessController.doPrivileged(AccessController.java:391) [?:?]
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85) [?:?]
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:740) [?:?]
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203) [?:?]
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124) [?:?]
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113) [?:?]
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109) [?:?]
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) [?:?]
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:90) [?:?]
i

Igor Demin

08/23/2021, 12:04 PM
I will look at it later, how it can be fixed. If you want to track it, you can fill an issue Until then you can use a workaround - set an icon directly, without passing it as a parameter
import androidx.compose.runtime.DisposableEffect
import androidx.compose.ui.window.Window
import androidx.compose.ui.window.application
import java.io.File
import javax.imageio.ImageIO

fun main() = application {
    Window(
        onCloseRequest = ::exitApplication
    ) {
        DisposableEffect(Unit) {
            window.iconImage = ImageIO.read(...)
            onDispose {  }
        }
    }
}
👍 1