view src/name/blackcap/imageprep/Main.kt @ 19:5fa5d15b4a7b

Attempt to make it a std. app. Builds, sorta runs, needs more work.
author David Barts <n5jrn@me.com>
date Fri, 20 Nov 2020 21:38:06 -0800
parents 884f1415a330
children 92afaa27f40a
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
import name.blackcap.kcli.CommandLine
import name.blackcap.kcli.InvalidArgumentException
import name.blackcap.kcli.Option
import name.blackcap.kcli.PromptingParser
import org.apache.commons.cli.HelpFormatter
import org.apache.commons.cli.Options
import org.apache.commons.cli.ParseException

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")
    }

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