我的屏幕在场景制作者的预览中可以很好地扩展:
但在运行时也不一样......
这是FXML的控制器类:
public class SelectionScreenController implements Initializable,
ControlledScreen {
@FXML
ToggleGroup rbgSelection;
@FXML
RadioButton radHazopEaXls;
@FXML
RadioButton radHaraEaXls;
@FXML
RadioButton radHaraXlsEa;
@FXML
RadioButton radHazopXlsEa;
@FXML
RadioButton radFmeaEaXls;
@FXML
RadioButton radFmeaXlsEa;
ScreensController myController;
@Override
public void initialize(URL url, ResourceBundle rb) {
SafetyDataExchange.primaryStage.sizeToScene();
}
public void setScreenParent(ScreensController screenParent) {
myController = screenParent;
}
@FXML
private void goToNextScreen(ActionEvent event) {
if (rbgSelection.getSelectedToggle().equals(radHaraEaXls)) {
myController.setScreen(SafetyDataExchange.screen2ID);
SafetyDataExchange.primaryStage.sizeToScene();
} else if (rbgSelection.getSelectedToggle().equals(radHaraXlsEa)) {
myController.setScreen(SafetyDataExchange.screen3ID);
SafetyDataExchange.primaryStage.sizeToScene();
} else if (rbgSelection.getSelectedToggle().equals(radHazopEaXls)) {
myController.setScreen(SafetyDataExchange.screen4ID);
SafetyDataExchange.primaryStage.sizeToScene();
}
}
}
这是FXML:
<BorderPane xmlns="http://javafx.com/javafx/8.0.111"
xmlns:fx="http://javafx.com/fxml/1"
fx:controller="at.v2c2.safetydataexchange.gui.SelectionScreenController">
<center>
<VBox spacing="10.0">
<children>
<GridPane VBox.vgrow="ALWAYS">
<columnConstraints>
<ColumnConstraints hgrow="ALWAYS" minWidth="10.0"
prefWidth="100.0" />
<ColumnConstraints hgrow="ALWAYS" minWidth="10.0"
prefWidth="100.0" />
<ColumnConstraints hgrow="ALWAYS" minWidth="10.0"
prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints vgrow="ALWAYS" />
<RowConstraints vgrow="ALWAYS" />
<RowConstraints vgrow="ALWAYS" />
</rowConstraints>
<children>
<Label text="HAZOP" />
<Label text="FMEA" GridPane.rowIndex="2" />
<RadioButton id="radHaraEaXls" fx:id="radHaraEaXls"
mnemonicParsing="false" selected="true" text="EA->XLS"
GridPane.columnIndex="1" GridPane.rowIndex="1">
<toggleGroup>
<ToggleGroup fx:id="rbgSelection" />
</toggleGroup>
</RadioButton>
<RadioButton id="radFmeaEaXls" fx:id="radFmeaEaXls"
mnemonicParsing="false" text="EA->XLS" toggleGroup="$rbgSelection"
GridPane.columnIndex="1" GridPane.rowIndex="2" />
<RadioButton id="radHazopXlsEa" fx:id="radHazopXlsEa"
mnemonicParsing="false" text="XLS->EA" toggleGroup="$rbgSelection"
GridPane.columnIndex="2" />
<RadioButton id="radFmeaXlsEa" fx:id="radFmeaXlsEa"
mnemonicParsing="false" text="XLS->EA" toggleGroup="$rbgSelection"
GridPane.columnIndex="2" GridPane.rowIndex="2" />
<Label text="HARA" GridPane.rowIndex="1" />
<RadioButton id="radHazopEaXls" fx:id="radHazopEaXls"
mnemonicParsing="false" text="EA->XLS" toggleGroup="$rbgSelection"
GridPane.columnIndex="1" />
<RadioButton id="radHaraXlsEa" fx:id="radHaraXlsEa"
mnemonicParsing="false" text="XLS->EA (csv)" toggleGroup="$rbgSelection"
GridPane.columnIndex="2" GridPane.rowIndex="1" />
</children>
</GridPane>
<Button mnemonicParsing="false" onAction="#goToNextScreen" text="Next"
/>
</children>
<padding>
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
</padding>
</VBox>
</center>
<top>
<MenuBar BorderPane.alignment="CENTER">
<menus>
<Menu mnemonicParsing="false" text="File">
<items>
<MenuItem mnemonicParsing="false" text="Exit" />
</items>
</Menu>
<Menu mnemonicParsing="false" text="Log">
<items>
<MenuItem mnemonicParsing="false" text="Toggle Hide/Show" />
</items>
</Menu>
<Menu mnemonicParsing="false" text="Help">
<items>
<MenuItem mnemonicParsing="false" text="About" />
</items>
</Menu>
</menus>
</MenuBar>
</top>
</BorderPane>
在Eclipse中刷新项目也无济于事。 有谁知道如何解决这个问题?