gpt4 book ai didi

swing - Clojure swing 应用程序启动时间

转载 作者:行者123 更新时间:2023-12-01 03:55:28 30 4
gpt4 key购买 nike

我刚刚开始使用 clojure 和跷跷板制作 GUI 应用程序。它只创建一个 JFrame 和几个组件。这是代码。 main 函数除了调用 start-gui 什么也不做并在返回后立即退出。

(ns pause.gui
(:use seesaw.core))

(native!)
; (javax.swing.UIManager/setLookAndFeel
; "org.pushingpixels.substance.api.skin.SubstanceGraphiteLookAndFeel")

(def main-window
(frame :title "Pause"
:on-close :exit))

(def sidebar (listbox :model []))
(def main-area (text :multi-line? true
:font "MONOSPACED-PLAIN-14"
:text "test"))

(def main-split
(left-right-split (scrollable sidebar)
(scrollable main-area)
:divider-location 1/5))

(defn setup-main-window
"Fills the main window with its content"
[main-window]
(config! main-window
:content main-split)
main-window)

(defn start-gui
"Create the main window"
[]
(-> main-window
setup-main-window
pack!
show!))

我使用 lein uberjar 编译了这个并用 time java -jar 计时.它报告了 14.5 秒。有什么我做错了吗?我对 3 秒启动没问题,但这是完全 Not Acceptable 。

最佳答案

遗憾的是,Clojure 仍有相当多的启动时间。这主要是因为 Clojure 在所有必需的命名空间中加载时发生的编译/代码加载量。

对于我编写的基于 Swing 的 GUI 应用程序,我经常编写 main Java 中的入口点,以便您可以快速向用户显示初始 GUI 或启动画面 - 而应用程序/Clojure 代码的其余部分在后台加载。

关于swing - Clojure swing 应用程序启动时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17644980/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com