选择方式:class或:跷跷板中的id

时间:2015-04-18 21:25:26

标签: user-interface clojure seesaw

以下是seesaw tutorial:

(def rbs (for [i [:source :doc]]
          (radio :id i :class :type :text (name i))))

(display (border-panel
           :north (horizontal-panel :items rbs)
           :center split
           :vgap 5
           :hgap 5
           :border 5))

(select f [:JRadioButton])
(select f [:.type])
(select f [:#source])

当选择:class时,在:type中添加了一个点,所以我们得到:.type,当按id选择时,添加了#,所以我们得到了:#source,为什么会这样?

1 个答案:

答案 0 :(得分:0)

这只是选择器语法的一部分,可让您指定要选择的内容。

docstring for the select function记录了完整的选择器语法。我不会复制整个文档字符串,但这里有一些亮点:

[:#id]            ID
[:tag]            "Simple" (not fully-qualified) class name 
[:<class-name>]   Fully-qualified class name; also matches subclasses
[:<class-name!>]  Exact class match
[:.<class>]       "Class" match, as set using :class option
[:*]              Everything

每个例子:

;; Widget with ID box1.
(select root [:#box1])
;; Class Label, e.g. com.myns.Label or org.foo.Label.
(select root [:Label])
;; javax.swing.text.JTextComponent and descendants.
(select root [:<javax.swing.text.JTextComponent>])
;; Only javax.swing.text.JTextComponent
(select root [:<javax.swing.text.JTextComponent!>])
;; Class class1, e.g. (flow-panel :class :class1)
(select root [:.class1])
;; Everything
(select root [:*])

另请注意,这些可以合并,例如

;; Everything under widgets with class javax.swing.text.JTextComponent
;; (or subclasses) and class input.
(select root [:<javax.swing.text.JTextComponent>.input :*])