我需要帮助在TilePane
(水平地包含在ScrollPane
)中插入对象。它会水平插入,直到到达ScrollPane
的末尾,然后开始添加到ScrollPane
的下一行。这就是它的样子:
该框是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>
我怎样才能完成我想做的事情?任何帮助,将不胜感激。谢谢!
答案 0 :(得分:0)
你可以使用ccs属性&#34;重复&#34;有了这样的背景,它将完成所有工作:
import java.util.HashMap;
import java.util.Map;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
public class SequenceNumber {
public static int getSequenceNumber (String TcOrderId){
// Create a hash map to set key values pair.
Map<String, Integer> map = new HashMap<String, Integer>();
int i= 1;
// check if hashmap contains the key.
System.out.println("key present " +map.containsKey(TcOrderId));
if (map.containsKey(TcOrderId))
{
//Key Present
System.out.println("Inside IF ");
int value = map.get(TcOrderId);
System.out.println("value from the key " + value);
map.remove(value);
map.put(TcOrderId, value+1);
return map.get(TcOrderId);
}
else
{
//Key Not present
System.out.println("INSIDE ELSE ");
map.put(TcOrderId, i);
System.out.println("map "+ map);
return map.get(TcOrderId);
}
}
public static void main(String[] args) throws IOException {
String sCurrentLine;
BufferedReader br = null;
try {
br = new BufferedReader(new FileReader("C:\\Users\\BongAn\\Desktop\\Package\\testing.txt"));
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
{
while ((sCurrentLine = br.readLine()) != null) {
//String orderid = sCurrentLine.substring(0, 6);
System.out.println("reading line " +sCurrentLine);
int seqvalue = getSequenceNumber(sCurrentLine);
System.out.println("seqvalue "+seqvalue);
}
}
}
要进行更多修改,请在Docs中查看背景属性。