0
我想我ImageView
從FXML文件 定位這是我FXML文件: -無法在FXML文件來定位的ImageView
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.String?>
<?import javafx.collections.FXCollections?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.ComboBox?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.TableColumn?>
<?import javafx.scene.control.TableView?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.layout.VBox?>
<AnchorPane fx:id="ap" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" prefHeight="480.0" prefWidth="911.0" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ch.Buildsapp.Main.BuildsController">
<children>
<VBox prefHeight="200.0" prefWidth="100.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
<HBox alignment="CENTER_LEFT" spacing="20.0" VBox.vgrow="NEVER">
<padding>
<Insets bottom="12.0" left="12.0" right="12.0" top="12.0" />
</padding>
<children>
<GridPane hgap="10.0" HBox.hgrow="NEVER">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<Label prefHeight="21.0" prefWidth="88.0" text="Platform" />
<ComboBox fx:id="versionCombo" prefHeight="31.0" prefWidth="108.0" GridPane.rowIndex="1">
<items>
<FXCollections fx:factory="observableArrayList">
<String fx:value="Win" />
<String fx:value="Mac" />
</FXCollections>
</items>
<value>
<String fx:value="Mac" />
</value>
</ComboBox>
<Label prefHeight="21.0" prefWidth="80.0" text="Product" GridPane.columnIndex="1" />
<ComboBox fx:id="verCombo" prefHeight="31.0" prefWidth="154.0" GridPane.columnIndex="1" GridPane.rowIndex="1">
</ComboBox>
<Label text="Version" GridPane.columnIndex="2" />
<ComboBox fx:id="versionNo" prefHeight="31.0" prefWidth="144.0" GridPane.columnIndex="2" GridPane.rowIndex="1" />
<Label prefHeight="21.0" prefWidth="60.0" text="Server" GridPane.columnIndex="3" />
<ComboBox fx:id="locCombo" prefHeight="31.0" prefWidth="103.0" GridPane.columnIndex="3" GridPane.rowIndex="1">
<items>
<FXCollections fx:factory="observableArrayList">
<String fx:value="SJ" />
<String fx:value="MN" />
</FXCollections>
</items>
<value>
<String fx:value="SJ" />
</value>
</ComboBox>
<Button fx:id="downloadButton" minWidth="80.0" mnemonicParsing="false" text="Download" GridPane.columnIndex="4" GridPane.rowIndex="1" />
<Button fx:id="installButton" minWidth="80.0" mnemonicParsing="false" text="Install" GridPane.columnIndex="5" GridPane.rowIndex="1" />
<Button fx:id="locButton" mnemonicParsing="false" prefHeight="31.0" prefWidth="120.0" text="Open Folder" GridPane.columnIndex="6" GridPane.rowIndex="1" />
</children>
</GridPane>
<ImageView fx:id="image" fitHeight="18.0" fitWidth="61.0" nodeOrientation="INHERIT" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@../../../../../../Downloads/info_512pxGREY.png" />
</image>
<HBox.margin>
<Insets />
</HBox.margin>
</ImageView>
</children>
</HBox>
<TableView fx:id="tableView" VBox.vgrow="ALWAYS">
<columns>
<TableColumn fx:id="builds" prefWidth="482.0" text="Builds" />
<TableColumn fx:id="date" minWidth="0.0" prefWidth="500.0" text="Date" />
</columns>
</TableView>
</children>
</VBox>
</children>
</AnchorPane>
我想要的形象出現在右上角,但它不是在那裏定位我試圖用「layoutX和layoutY」來改變X和Y座標,但這似乎並不奏效。
是否有任何理由爲什麼您在節點層次結構中的該點添加了'ImageView',而不是作爲根'AnchorPane'的子節點?此外,在將來請通過確保發佈證明您的問題的[最簡單示例](http://stackoverflow.com/help/mcve)來幫助那些試圖幫助您的人。你已經添加了很多'節點',有點難以找到你所要求的'Node'... – fabian
爲什麼不把它添加到你的'GridPane'的最後一列,rowSpan = 2,而不是添加它到'HBox'? – DVarga
@Fabian下次我會照顧最小的例子,我嘗試了你的建議,但它是來到左上角,我無法將它移到右上角。 – user3649361