I have created a basic window in Swing using Kotlin and I have an issue when displaying when I'm in Hyprland. The window sometimes starts as a floating window and sometimes it starts tiled. No idea what could cause this.
Here is what I have so far implemented in my window class:
class Window: JFrame() {
private val displayMode = GraphicsEnvironment.getLocalGraphicsEnvironment().defaultScreenDevice.displayMode
private val transform = GraphicsEnvironment.getLocalGraphicsEnvironment().defaultScreenDevice.defaultConfiguration.defaultTransform
companion object {
private const val DEFAULT_TITLE = "Main WIndow"
private const val BORDER_RATIO = 0.15
private const val WINDOW_RATIO = 1 - BORDER_RATIO * 2
}
override fun getPreferredSize(): Dimension? {
setDefaultLocale(null)
return Dimension(displayMode.width, displayMode.height)
}
override fun getBounds(): Rectangle {
val screenHeight = (displayMode.width / transform.scaleY).toInt()
val screenWidth = (displayMode.width / transform.scaleX).toInt()
return Rectangle(
(screenWidth * BORDER_RATIO).toInt(),
(screenHeight * BORDER_RATIO).toInt(),
(screenWidth * WINDOW_RATIO).toInt(),
(screenHeight * WINDOW_RATIO).toInt()
)
}
override fun getName(): String? = DEFAULT_TITLE
}