[英]JavaFX: why scrollpane is including a splitpane?
我試圖了解JavaFX中的小部件如何工作,並且鑒於以下FXML,我不明白為什么ScrollPane
在ListView
之后放入拆分:
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.ListView?>
<?import javafx.scene.control.ScrollPane?>
<?import javafx.scene.control.ToolBar?>
<?import javafx.scene.Group?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.Pane?>
<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="500.0"
prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
<top>
<Pane prefHeight="195.0" prefWidth="600.0" BorderPane.alignment="CENTER">
<children>
<Group>
<children>
<Label layoutX="58.0" layoutY="25.0" prefHeight="15.0" prefWidth="80.0" text="Testlabel "/>
</children>
</Group>
</children>
</Pane>
</top>
<center>
<ScrollPane fx:id="scrollPane" prefHeight="200.0" prefWidth="600.0" BorderPane.alignment="CENTER">
<content>
<ListView/>
</content>
</ScrollPane>
</center>
<bottom>
<ToolBar layoutX="-86.0" layoutY="150.0" prefWidth="200.0">
<items>
</items>
</ToolBar>
</bottom>
</BorderPane>
我只想有一個ListView
,如果列表太長,可以滾動。 使用Linux Mint上最新JDK 8(1.8.0_05)中包含的JavaFX。
將minWidth="600"
為ListView
的屬性可解決此問題:
<ScrollPane fx:id="scrollPane" prefHeight="100.0" prefWidth="600.0" BorderPane.alignment="CENTER">
<ListView minWidth="600"/>
</ScrollPane>
但是我必須承認這是完全不直觀的。 JavaFX應該自己弄清楚首選寬度是多少。 像Swing人開發JavaFX一樣聞起來。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.