Skip to content

Commit 1fa5f89

Browse files
committed
SwingMainWindow: add component listener that updates sciview's window dimensions after a resize event
1 parent da55899 commit 1fa5f89

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

src/main/kotlin/sc/iview/ui/SwingMainWindow.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ import java.util.*
5252
import javax.script.ScriptException
5353
import javax.swing.*
5454
import kotlin.concurrent.thread
55+
import kotlin.math.log
5556
import kotlin.math.roundToInt
5657

5758

@@ -235,6 +236,12 @@ class SwingMainWindow(val sciview: SciView) : MainWindow() {
235236
frame.add(mainSplitPane, BorderLayout.CENTER)
236237
frame.add(toolbar, BorderLayout.EAST)
237238
frame.defaultCloseOperation = JFrame.DO_NOTHING_ON_CLOSE
239+
frame.addComponentListener(object : ComponentAdapter() {
240+
override fun componentResized(e: ComponentEvent) {
241+
sciview.windowWidth = e.component.width
242+
sciview.windowHeight = e.component.height
243+
}
244+
})
238245
frame.addWindowListener(object : WindowAdapter() {
239246
override fun windowClosing(e: WindowEvent) {
240247
logger.debug("Closing SciView window.")

0 commit comments

Comments
 (0)