view src/name/blackcap/imageprep/Main.kt @ 31:99a0eb385c9a default tip

Work around annoying Swing glitch.
author David Barts <n5jrn@me.com>
date Sat, 20 Aug 2022 09:19:49 -0700
parents 098c4f5507c7
children
line wrap: on
line source

/*
 * Entry point, etc.
 */
package name.blackcap.imageprep

import java.io.File
import java.util.logging.Level
import java.util.logging.Logger
import javax.swing.UIManager

object Application {
    /* name we call ourselves */
    val MYNAME = "ImagePrep"

    /* global UI objects */
    var mainFrame: MainFrame by setOnce()
    var helpDialog: HelpDialog by setOnce()
    var settingsDialog: SettingsDialog by setOnce()

    fun initialize() {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        mainFrame = MainFrame() /* must be created first */
        settingsDialog = SettingsDialog()
        mainFrame.jMenuBar = MyMenuBar()
        setMacMenus() /* always safe to call; no-op if not a Mac */
        helpDialog = HelpDialog()
        mainFrame.setVisible(true)
    }
}

fun main(args: Array<String>) {
    /* start up */
    LOGGER.log(Level.INFO, "beginning execution")
    if (OS.type == OS.MAC) {
        System.setProperty("apple.laf.useScreenMenuBar", "true")
        System.setProperty("apple.awt.application.name", Application.MYNAME)
    }

    /* launch GUI */
    inSwingThread {
        Application.initialize()
    }
}