Scrollbar for Legend
Legend繼承了Tile,但是覆寫了HorizontalScrollPolicy 以及 VerticalScrollPolicy,都固定為 OFF 。可是,如果Legend 項目太長,又不想被裁切掉,除了Monkey-patch Legend類別之外,可以用一個VBox 把它包住,特別的是,要這麼設定:
[xml]
minHeight="80"
minWidth="30"
horizontalScrollPolicy="off"
verticalScrollPolicy="auto"
>
[/xml]
主角Legend不要做任何的設定, 也不要給height=100%,讓VBox去觀察裡面的Legend即可。
As far as I know Legend extends Tile Class. Furthermore, it overrides HorizontalScrollPolicy and VerticalScrollPolicy, forcing them to be “OFF” always. However, sometimes we need scrollbars for considerable number of legend items. In this case, we could monkey-patch Legend class. Or we can create a container such as VBox to display scrollbars. This way, we write up code:
[xml]
minHeight="80"
minWidth="30"
horizontalScrollPolicy="off"
verticalScrollPolicy="auto"
>
[/xml]
This ends up a legend with vertical scrollbar. Here is another thing. Do not assign any initials to width or height of legend. Otherwise it layouts itself regardless our plan. Actually we delegate the layout work to the new parent container so that we let legend draw anything it wants. Finally the parent container handles scrollbars.
