[英]JavaFX 8 TabPane - Tab buttons keep getting scrolled out of the viewport of TabPane header
I got a really weird issue with a TabPane
that has its tab buttons on the left. 我在
TabPane
上遇到了一个非常奇怪的问题,它的选项卡按钮在左侧。 The problem is only present during runtime of applications but not in the SceneBuilder (2.0) preview. 该问题仅在应用程序运行时出现,而在SceneBuilder(2.0)预览中不存在。
Every time the selected Tab
changes (either by user click or by changing the selectedIndex
via code) the tabs shift their position upwards and out of the viewport of the tab button area as you can see in the examplary picture below . 每次更改
Tab
(通过用户单击或通过代码更改selectedIndex
),选项卡都将其位置向上移动并移出选项卡按钮区域的视口,如下面的示例图片所示。 The amount of pixels shifted seems to depend on the width of the TabPane
(the lower the width, the more it shifts) and most of the time the buttons in my TabPane
are shifted completely out of the viewport. 像素移位量似乎取决于
TabPane
的宽度(宽度越小,移位量越大)以及大多数时候TabPane
中的按钮完全移出视口。
It is possible to get the tab buttons back to their normal position by focusing a different window or by scrolling upwards or downwards in the tab button area. 通过聚焦不同的窗口或在选项卡按钮区域中向上或向下滚动,可以将选项卡按钮恢复到其正常位置。 Once they are back in their normal positions they're only shifted again when the selected tab changes again.
一旦它们恢复到正常位置,它们只会在所选选项卡再次更改时再次移位。
I tried to access the TabHeaderSkin
objects (style class "tab") that seem to be the only runtime objects in the TabPane
header area that change as result of the shifting. 我试图访问
TabHeaderSkin
对象(样式类“ tab”),这些对象似乎是TabPane
标头区域中唯一因运行而更改的运行时对象。 According to Scenic View, their localY
value changes. 根据Scenic View,它们的
localY
值会发生变化。 However, myTabPane.lookupAll(".tab")
finds nothing. 但是,
myTabPane.lookupAll(".tab")
找不到任何内容。
Except from that, there seems to be no possibility at all to access the auto scroll behavior or tab button positions or things like that. 除此之外,似乎根本不可能访问自动滚动行为或选项卡按钮位置或类似内容。
Edit 编辑
Here's an MCVE-FXML 这是MCVE-FXML
<?import javafx.scene.control.*?>
<?import java.lang.*?>
<?import javafx.scene.layout.*?>
<HBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="20.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
<children>
<TabPane side="LEFT" tabClosingPolicy="UNAVAILABLE">
<tabs>
<Tab text="Untitled Tab 1">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" />
</content>
</Tab>
<Tab text="Untitled Tab 2">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" />
</content>
</Tab>
<Tab text="Untitled Tab">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" />
</content>
</Tab>
<Tab text="Untitled Tab">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" />
</content>
</Tab>
</tabs>
</TabPane>
</children>
</HBox>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.