korlibs / korlibs/korge

JVM Window extended due to JFrame's default BorderLayout Insets

Open
#1,383 10 comments 0 reactions 0 assignees View on GitHub
Dominant language
Kotlin
Stars
3k
Forks
148
Avg merge
13h 44m
Merged PRs (30d)
1

Description

A simple Korge example with jvm target results in the window being larger than the desired height, where the top and bottom contains black borders.

An example:
```kotlin
suspend fun main() = Korge(width = 320, height = 240) {

solidRect(320, 240)
}
```

yields the following:
![image](https://user-images.githubusercontent.com/1859669/222556110-ae43e9cf-deba-4516-8838-aab69c5a47c1.png)

I believe this is due to the underlying `JFrame`'s default layout manager, which is the `BorderLayout`. During [frame.pack()](https://github.com/korlibs/korge/blob/main/korgw/src/jvmMain/kotlin/com/soywiz/korgw/awt/AwtGameWindow.kt#L263) in `AwtGameWindow`, the preferred size is expanded by the `Insets.top` and `Insets.bottom` of the `BorderLayout`.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in korgw/src/jvmMain/kotlin/com/soywiz/korgw/awt/AwtGameWindow.kt around the frame.pack() call, and reproduce the issue with the Kotlin Korge example from the report. Check how the JFrame layout and insets affect the preferred size; done means a 320x240 JVM window no longer gains the reported top and bottom borders.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, kotlin
Domain
desktop
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.