最后一步是將FXDNode節(jié)點指定給Scene對象的content屬性。全部代碼如下所示:
/*
* Chapter6.fx
*
* v1.0 - J. F. DiMarzio
*
* 5/17/2010 – created
*
* Working with images
*
*/
package com.jfdimarzio.javafxforbeginners;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.fxd.FXDNode;
var butterflyGroup : FXDNode = FXDNode{
url:"{__DIR__}images/butterfly.fxz"
};
var butterfly = butterflyGroup.getNode("butterfly");
butterfly.translateX = 50;
butterfly.translateY = 50;
butterfly.rotate = 45;
/**
* @author JFDiMarzio
*/
Stage {
title : "FXZ Images"
scene: Scene {
content:[ butterflyGroup]
}
}
使用Desktop配置文件運行代碼,可看到butterfly圖層已經(jīng)旋轉(zhuǎn)移動到背景下,如圖6-7所示。