[英]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.