3.5.2.2.10. 滚动盒子布局

在线示例

API 文档

ScrollBoxLayout − 一个支持内容滚动的容器。

gui scrollBox

该组件的 XML 名称: scrollBox

下面是一个 XML 描述示例:

  1. <groupBox caption="Order" width="300" height="170">
  2. <scrollBox width="100%" height="100%" spacing="true" margin="true">
  3. <dateField dataContainer="orderDc" property="date" caption="Date"/>
  4. <lookupField dataContainer="orderDc" property="customer" optionsContainer="customersDc" caption="Customer"/>
  5. <textField dataContainer="orderDc" property="amount" caption="Amount"/>
  6. </scrollBox>
  7. </groupBox>
  • 组件排列的方向可以通过 orientation 属性定义 ,可选值: horizontalvertical。默认为 vertical
  • scrollBars 属性可以配置滚动条。它的值可以是 horizontal 或者 vertical - 分别用于水平滚动和垂直滚动,both - 两个方向都有滚动条。将值设置为 none 禁止向任何方向的滚动。
  • contentHeight - 设置内容高度。
  • contentWidth - 设置内容宽度。
  • contentMaxHeight - 设置内容的最大 CSS 高度,例如,"640px""100%"
  • contentMinHeight - 设置内容的最小 CSS 高度,例如,"640px""auto"
  • contentMaxWidth - 设置内容的最大 CSS 宽度,例如,"640px""100%"
  • contentMinWidth - 设置内容的最小 CSS 宽度,例如,"640px""auto"
  1. <layout>
  2. <scrollBox contentMinWidth="600px"
  3. contentMinHeight="200px"
  4. height="100%"
  5. width="100%">
  6. <textArea height="150px"
  7. width="800px"/>
  8. </scrollBox>
  9. </layout>

gui scrollBox 1

Figure 23. 带有 textArea 的显示完整的 scrollBox

gui scrollBox 2

Figure 24. 窗口尺寸调整时滚动条出现,管理内容的宽度



建议设置内容的高和宽,否则,放置在 scrollBox 中的组件只能有固定大小或默认大小。



如果没有设置内容高和宽,不要给嵌套组件设置 height="100%"width="100%" 属性。

可以在 ScrollBox 中使用快捷键。使用 addShortcutAction() 方法设置快捷键和要执行的操作:

  1. scrollBox.addShortcutAction(new ShortcutAction("SHIFT-A", shortcutTriggeredEvent ->
  2. notifications.create()
  3. .withCaption("SHIFT-A action")
  4. .show()
  5. ));

scrollBox 的属性

align - caption - captionAsHtml - contextHelpText - contextHelpTextHtmlEnabled - css - description - descriptionAsHtml - box.expandRatio - height - id - margin - orientation - scrollBars - spacing - stylename - width
API

add - addShortcutAction - getComponent - getComponentNN - getComponents - getMargin - getOwnComponent - getOwnComponents - indexOf - remove - removeAll - setMargin - setSpacing