如何在跷跷板中使用滑块

  • 本文关键字:跷跷板 clojure seesaw
  • 更新时间 :
  • 英文 :


我是clojure的新手(甚至不是跷跷板),但有很多Java经验和相当多的摇摆经验。

我正在尝试创建一个带有一些下拉文本框和滑块的窗口。但是,我无法将所有部分显示在一个窗口上(而不是一次显示一个),并且由于某种原因滑块未显示。

真的找不到很多关于这个的教程,所以也许我错过了一些明显的东西。

这是我正在尝试做的...

    (defn window [cuisine-input rating-input location-slider]
        (seesaw/frame
        :title "Resturant Selector"
        :content (cuisine-input rating-input location-slider)
        :width 200
        :height 50
        :on-close :exit))

    (defn -main
    [& args]
        (def cuisine (seesaw/input "Please choose a type of cuisine: "
                           :choices ["Indian" "Japanese" "Chinese"
                                     "Burgers"]))
        (def rating (seesaw/input "Please choose the ideal rating: "
                        :choices ["1 star" "2 stars" "3 stars" "4 stars" 
                                  "5 stars"]))
        (def location (seesaw/slider 
                             :value 5 :min 0 :max 20 
                             :minor-tick-spacing 1 :major-tick-spacing 2 
                             :snap-to-ticks? true 
                             :paint-ticks? true :paint-labels? true))
        (def main-window (window cuisine rating location))
        (seesaw/pack! (window main-window))
        (seesaw/show! (window main-window))

我也尝试过这样的事情:

    (seesaw/frame :title "Resturant Selector" :on-close :exit
            :content (:items [ 
                     (seesaw/input "Please choose a type of cuisine: "
                           :choices ["Indian" "Japanese" "Chinese"
                                    "Burgers"])
                     (seesaw/input "Please choose the ideal rating: "
                        :choices ["1 star" "2 stars" "3 stars" "4 stars" 
                                  "5 stars"])
                     (seesaw/slider
                       :value 5 :min 0 :max 20
                       :minor-tick-spacing 1 :major-tick-spacing 2
                       :snap-to-ticks? true
                       :paint-ticks? true :paint-labels? true)]
                              )
            )

seesaw/input 创建一个输入对话框,而你想要创建一个 JComboBox。维基对如何创建小部件有很好的帮助,你可以在API文档中找到可用小部件的列表。

要在框架中包含多个小部件,您需要一个容器。

因此,对于您的特定示例,您将需要类似于以下内容的内容:

(defn window [content]
  (seesaw/frame
    :title "Resturant Selector"
    :content content
    :width 200
    :height 50
    :on-close :close))
(defn -main
  [& args]
  (let [rating-label (seesaw/label :text "Please choose rating:")
        rating (seesaw/combobox :model ["1 star" "2 star"])
        location (seesaw/slider
                   :value 5 :min 0 :max 20
                   :minor-tick-spacing 1 :major-tick-spacing 2
                   :snap-to-ticks? true
                   :paint-ticks? true :paint-labels? true)
        main-window (window (seesaw/vertical-panel :items [rating-label rating location]))]
    (seesaw/invoke-later
      (seesaw/pack! main-window)
      (seesaw/show! main-window))))

相关内容

  • 没有找到相关文章

最新更新