(翻译)第二十六回 JavaFX2.0 标题窗格TitledPane和手风琴控件Accordion
原文地址http://download.oracle.com/javafx/2.0/ui_controls/accordion-titledpane.htm#CACGBAHI
?
?
?
标题窗格就是带有标题的面板,可以被打开和关闭,也可以被包进任何Node元素,诸如UI控件、图片、计入布局容器的元素组。
标题窗格可以用手风琴控件来形成组。手风琴控件能创建多个窗格而每次只显示一个。Figure 20-1是带有3个标题窗格的手风琴控件。
?
Description of "Figure 20-1 Accordion with Three Titled Panes"
?
JavaFX SDK API中的 Accordion和 TitledPane 类用来实现这样的控件。
Description of "Figure 20-2 Titled Pane with a Button"
Description of "Figure 20-3 Titled Pane with Some Text"
不要明确指定标题窗格的最小、最大和优先的高度值,这样在打开关闭时可能导致难以预料的行为。
?Example 20-2 在的代码添加了几个控件到标题窗格,然后加入到了GridPane布局容器。
?
Description of "Figure 20-4 Titled Pane that Contains Several Controls"
可以定义标题窗格打开关闭的方式。默认地,标题窗格是可伸缩的,它们的移动也是动画。如果要阻止标题窗格关闭,将setCollapsible方法设为false。也可以将 setAnimated 方法设为false来关闭动画打开效果。Example 20-3 中的代码实现了该任务。
?
Description of "Figure 20-5 Accordion with Three Titled Panes"
Description of "Figure 20-6 Initial View of the TitledPaneSample Application"
?
如果打开的是Leaves标题窗格,Attachment标签就变成"Leaves.jpg,"见Figure 20-7.
Description of "Figure 20-7 TitledPaneSample Application with the Leaves Titled Pane Expanded"
TitledPane和Accordion类都继承了Node类,所以可以应用特效和使用CSS。