【发布时间】:2015-06-15 12:15:55
【问题描述】:
我决定开始学习 FXML,我想做的第一件事就是创建背景图像。我之前在 javafx 中添加了背景图像,我认为在 FXML 中添加背景图像的过程与您在 javafx 中所做的有点相似。我错过了什么?
这是我的 FXML 文件
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.image.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<VBox fx:id="menu" spacing = "20" alignment="TOP_CENTER" xmlns:fx="http://javafx.com/fxml/1" fx:controller="millionairetriviagame.MenulayoutFXMLController">
<StackPane>
<ImageView>
<image>
<Image url="@ImageFiles/BlueBackgroundColor.jpg" />
</image>
</ImageView>
</StackPane>
</VBox>
我在 javafx 中的主要课程
public class MillionaireTriviaGame extends Application
{
@Override
public void start(Stage menuStage) throws Exception
{
Parent object = FXMLLoader.load(getClass().getResource("MenulayoutFXML.fxml"));
Scene menuScene = new Scene(object, 640, 480);
menuStage.setTitle("Let's play who wants to be a millionaire");
menuStage.setScene(menuScene);
menuStage.show();
}
public static void main(String[] args)
{
launch(args);
}
}
我的项目目录(我正在使用的项目是 MillionaireTriviaGame)
【问题讨论】:
标签: java image background javafx fxml