我正在尝试将带有 ImageView 子项的 TilePane 添加到 JavaFX 中的场景中。目前,我的 FXML 正在加载一个空的 TilePane。
我制作 TilePane 的当前 FXML 行是
<TilePane id="MapPane" fx:id="mapPane" layoutX="3.0" layoutY="0.0" prefColumns="9" prefHeight="560.0" prefTileHeight="112.0" prefTileWidth="112.0" prefWidth="1277.0" visible="true"\>
其中 mapPane 是我的 .java 文件中的变量名称
controller: /* * 要更改此模板,请选择 Tools | 模板 * 并在编辑器中打开模板。*/ 包screens.gameScreen;
import screens.*;
import mule.*;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.layout.*;
import java.awt.MouseInfo;
import java.awt.Point;
import com.sun.glass.ui.Robot;
/**
* FXML Controller class
*
* @author Stephen
*/
public class GameScreenController implements Initializable, ControlledScreen {
Robot robot = com.sun.glass.ui.Application.GetApplication().createRobot();
ScreenManager screenManager;
TileEngine tileEngine = new TileEngine();
@FXML
TilePane mapPane = tileEngine.createRandomMap(true);;
/**
* Initializes the controller class.
*/
@Override
public void initialize(URL url, ResourceBundle rb) {
}
@Override
public void setScreenParent(ScreenManager screen) {
screenManager = screen;
}
@FXML
private void goToMain(ActionEvent event) {
screenManager.setScreen(mule.MULE.mainMenuScreenID);
}
}