質問編集履歴
1
hello\.fxmlを読み込むクラス"HelloController"の記述が抜け落ちておりました。 申し訳ありません。 ●以下追記●部分に追記しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -244,6 +244,104 @@
|
|
244
244
|
|
245
245
|
|
246
246
|
|
247
|
+
|
248
|
+
|
249
|
+
●以下追記●
|
250
|
+
|
251
|
+
public class HelloController extends AnchorPane implements Initializable{
|
252
|
+
|
253
|
+
|
254
|
+
|
255
|
+
@FXML private Button helloButton;
|
256
|
+
|
257
|
+
@FXML private Label helloLabel;
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
private int cnt;
|
262
|
+
|
263
|
+
/** ラベルに表示するテキスト */
|
264
|
+
|
265
|
+
private final String labelText;
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
|
270
|
+
|
271
|
+
public HelloController(String labelText) {
|
272
|
+
|
273
|
+
this.labelText = labelText;
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
loadFXML();
|
278
|
+
|
279
|
+
}
|
280
|
+
|
281
|
+
|
282
|
+
|
283
|
+
/**
|
284
|
+
|
285
|
+
* FXMLのロード
|
286
|
+
|
287
|
+
*/
|
288
|
+
|
289
|
+
private void loadFXML() {
|
290
|
+
|
291
|
+
|
292
|
+
|
293
|
+
FXMLLoader fxmlLoader = new FXMLLoader(HelloWorld02.class.getResource("hello.fxml"));
|
294
|
+
|
295
|
+
fxmlLoader.setRoot(this);
|
296
|
+
|
297
|
+
|
298
|
+
|
299
|
+
// 自分自身をコントロールとして設定
|
300
|
+
|
301
|
+
fxmlLoader.setController(this);
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
try {
|
306
|
+
|
307
|
+
fxmlLoader.load();
|
308
|
+
|
309
|
+
} catch (IOException exception) {
|
310
|
+
|
311
|
+
throw new RuntimeException(exception);
|
312
|
+
|
313
|
+
}
|
314
|
+
|
315
|
+
}
|
316
|
+
|
317
|
+
|
318
|
+
|
319
|
+
@FXML
|
320
|
+
|
321
|
+
public void onHelloButtonClicked() {
|
322
|
+
|
323
|
+
HelloWorld02.getInstance().sendMoveController("進む");
|
324
|
+
|
325
|
+
}
|
326
|
+
|
327
|
+
|
328
|
+
|
329
|
+
@Override
|
330
|
+
|
331
|
+
public void initialize(URL url, ResourceBundle rb) {
|
332
|
+
|
333
|
+
// label.setText(labelText);
|
334
|
+
|
335
|
+
}
|
336
|
+
|
337
|
+
|
338
|
+
|
339
|
+
}
|
340
|
+
|
341
|
+
|
342
|
+
|
343
|
+
|
344
|
+
|
247
345
|
●●●●●●●●hello.fxml●●●●●●●●●●●●●
|
248
346
|
|
249
347
|
<fx:root prefHeight="480.0" prefWidth="640.0" type="javafx.scene.layout.AnchorPane" xmlns="http://javafx.com/javafx/8.0.60" xmlns:fx="http://javafx.com/fxml/1">
|