0
TilePane
(ScrollPane
に含まれています)にオブジェクトを挿入するのに役立つ必要があります。それはScrollPane
の終わりに達するまで水平に挿入し、ScrollPane
の次の行に追加を開始します。これは、次のようになります。JavaFXは水平方向にTilePaneのオブジェクトを追加します(ScrollPane内のTilePane)
ボックスがScrollPane
で、TilePane
は、すべての画像を保持しているものです。
基本的には、TilePane
は右側に追加し続けて、水平方向のスクロールバーを表示するようにします。ScrollPane
は、ここに私のコードです:
private void start()
{
@FXML private ImageView bigImage;
@FXML private ScrollPane scrollPane;
@FXML private TilePane tilePane;
// Setup scrollpane
scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED);
scrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
tilePane.setHgap(15);
for(int i = 0; i < 10; i++)
{
ImageView imageView = new ImageView(bigImage.getImage());
imageView.setFitWidth(100);
imageView.setFitHeight(100);
tilePane.getChildren().add(imageView);
}
//scrollPane.setFitToWidth(true);
scrollPane.setContent(tilePane);
}
FXML:
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.ScrollPane?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.TilePane?>
<AnchorPane prefHeight="700.0" prefWidth="900.0" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1" fx:controller="view.PhotoController">
<children>
<ImageView fx:id="bigImage" fitHeight="441.0" fitWidth="534.0" layoutX="35.0" layoutY="52.0" pickOnBounds="true">
<image>
<Image url="@../../../../../../Pictures/Wallpaper02.jpg" />
</image>
</ImageView>
<ScrollPane fx:id="scrollPane" layoutX="35.0" layoutY="528.0" prefHeight="140.0" prefWidth="820.0">
<content>
<TilePane fx:id="tilePane" prefHeight="137.0" prefWidth="817.0" />
</content>
</ScrollPane>
</children>
</AnchorPane>
どのように私は私が何をしたいのかを達成することができますか?どんな助けもありがとう。ありがとうございました!
これは何もしませんでした。画像はまだ右の代わりに次の行に挿入されます。 – syy