回答編集履歴
2
add
test
CHANGED
@@ -33,3 +33,89 @@
|
|
33
33
|
```
|
34
34
|
|
35
35
|
mainPaneに表示したい項目が複雑なのであれば、別途fxmlファイルと対応するContollerクラスを定義し、HelloView.fxmlファイルと同様にloadして、mainPaneに追加すればいい。
|
36
|
+
|
37
|
+
----
|
38
|
+
|
39
|
+
> 手を尽くしたのですがAssetsページに別fxmlを利用するとどうしても別ウィンドウで開かれてしまい思ったように動作しません
|
40
|
+
|
41
|
+
|
42
|
+
```diff
|
43
|
+
HelloController.java
|
44
|
+
import javafx.fxml.FXML;
|
45
|
+
+import javafx.fxml.FXMLLoader;
|
46
|
+
import javafx.scene.layout.AnchorPane;
|
47
|
+
|
48
|
+
public class HelloController {
|
49
|
+
@@ -20,14 +24,28 @@
|
50
|
+
@FXML
|
51
|
+
private AnchorPane mainPane;
|
52
|
+
|
53
|
+
+ @FXML
|
54
|
+
+ private Button assetsButton;
|
55
|
+
+
|
56
|
+
@FXML
|
57
|
+
protected void onClickHome(ActionEvent evt) {
|
58
|
+
System.out.println("Clicked");
|
59
|
+
}
|
60
|
+
|
61
|
+
@FXML
|
62
|
+
- void initialize() {
|
63
|
+
+ void initialize() throws Exception {
|
64
|
+
assert mainPane != null : "fx:id=\"mainPane\" was not injected: check your FXML file 'HelloView.fxml'.";
|
65
|
+
|
66
|
+
+ final AnchorPane subPanel = FXMLLoader.load(this.getClass().getResource("./SubPanel.fxml"));
|
67
|
+
+ AnchorPane.setTopAnchor(subPanel, 0.);
|
68
|
+
+ AnchorPane.setBottomAnchor(subPanel, 0.);
|
69
|
+
+ AnchorPane.setLeftAnchor(subPanel, 0.);
|
70
|
+
+ AnchorPane.setRightAnchor(subPanel, 0.);
|
71
|
+
+
|
72
|
+
+ assetsButton.setOnAction(ev -> {
|
73
|
+
+ mainPane.getChildren().clear();
|
74
|
+
+// mainPane.getChildren().add(new Label(LocalDateTime.now().toString()));
|
75
|
+
+ mainPane.getChildren().add(subPanel);
|
76
|
+
+ });
|
77
|
+
}
|
78
|
+
}
|
79
|
+
```
|
80
|
+
|
81
|
+
```diff
|
82
|
+
SubPanel.fxml
|
83
|
+
+<?xml version="1.0" encoding="UTF-8"?>
|
84
|
+
+
|
85
|
+
+<?import javafx.scene.control.Button?>
|
86
|
+
+<?import javafx.scene.control.Label?>
|
87
|
+
+<?import javafx.scene.control.TextArea?>
|
88
|
+
+<?import javafx.scene.layout.AnchorPane?>
|
89
|
+
+<?import javafx.scene.layout.ColumnConstraints?>
|
90
|
+
+<?import javafx.scene.layout.GridPane?>
|
91
|
+
+<?import javafx.scene.layout.HBox?>
|
92
|
+
+<?import javafx.scene.layout.RowConstraints?>
|
93
|
+
+
|
94
|
+
+
|
95
|
+
+<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="278.0" prefWidth="344.0" xmlns="http://javafx.com/javafx/8.0.161" xmlns:fx="http://javafx.com/fxml/1">
|
96
|
+
+ <children>
|
97
|
+
+ <GridPane layoutX="14.0" layoutY="90.0" prefHeight="278.0" prefWidth="344.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
98
|
+
+ <columnConstraints>
|
99
|
+
+ <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
100
|
+
+ <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
101
|
+
+ </columnConstraints>
|
102
|
+
+ <rowConstraints>
|
103
|
+
+ <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
104
|
+
+ <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
105
|
+
+ <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
106
|
+
+ </rowConstraints>
|
107
|
+
+ <children>
|
108
|
+
+ <HBox alignment="CENTER_RIGHT" GridPane.columnSpan="2147483647" GridPane.rowIndex="2">
|
109
|
+
+ <children>
|
110
|
+
+ <Button mnemonicParsing="false" text="Button" />
|
111
|
+
+ <Button mnemonicParsing="false" text="Button" />
|
112
|
+
+ <Button mnemonicParsing="false" text="Button" />
|
113
|
+
+ </children>
|
114
|
+
+ </HBox>
|
115
|
+
+ <TextArea prefHeight="200.0" prefWidth="200.0" GridPane.columnSpan="2147483647" GridPane.rowIndex="1" />
|
116
|
+
+ <Label text="Label" />
|
117
|
+
+ </children>
|
118
|
+
+ </GridPane>
|
119
|
+
+ </children>
|
120
|
+
+</AnchorPane>
|
121
|
+
```
|
1
typo
test
CHANGED
@@ -32,5 +32,4 @@
|
|
32
32
|
}
|
33
33
|
```
|
34
34
|
|
35
|
-
mainPane
|
35
|
+
mainPaneに表示したい項目が複雑なのであれば、別途fxmlファイルと対応するContollerクラスを定義し、HelloView.fxmlファイルと同様にloadして、mainPaneに追加すればいい。
|
36
|
-
HelloView.fxmlファイルと同様にloadして、mainPanelに追加すればいい。
|