首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >通过:class或:id在seesaw中选择

通过:class或:id在seesaw中选择
EN

Stack Overflow用户
提问于 2015-04-19 05:25:26
回答 1查看 131关注 0票数 1

这是来自seesaw tutorial:

代码语言:javascript
复制
(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])

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

EN

回答 1

Stack Overflow用户

发布于 2015-04-24 07:10:37

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

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

代码语言:javascript
复制
[:#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

每种方法的示例:

代码语言:javascript
复制
;; 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 [:*])

还请注意,这些可以组合在一起,例如

代码语言:javascript
复制
;; Everything under widgets with class javax.swing.text.JTextComponent
;; (or subclasses) and class input.
(select root [:<javax.swing.text.JTextComponent>.input :*])
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29723045

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档