teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

1

コードの修正及び追加

2018/08/09 11:48

投稿

CreeperSaviour
CreeperSaviour

スコア129

title CHANGED
File without changes
body CHANGED
@@ -21,10 +21,8 @@
21
21
  package application;
22
22
 
23
23
  import javafx.application.Application;
24
- import javafx.fxml.FXML;
25
24
  import javafx.fxml.FXMLLoader;
26
25
  import javafx.scene.Scene;
27
- import javafx.scene.control.TextField;
28
26
  import javafx.scene.input.KeyEvent;
29
27
  import javafx.scene.layout.AnchorPane;
30
28
  import javafx.stage.Stage;
@@ -45,9 +43,6 @@
45
43
  }
46
44
  }
47
45
 
48
- @FXML
49
- private static TextField textField;
50
-
51
46
  public static void main(String[] args) {
52
47
  launch(args);
53
48
  }
@@ -510,7 +505,7 @@
510
505
  default:
511
506
  break;
512
507
  }
513
- textField.setText(fulltext);
508
+ if(fulltext != null) bbb.textField.setText(fulltext);
514
509
  System.out.println(fulltext);
515
510
  }
516
511
 
@@ -518,6 +513,28 @@
518
513
 
519
514
  ```
520
515
 
516
+ bbb.java
517
+ ```
518
+ package application;
519
+
520
+ import java.net.URL;
521
+ import java.util.ResourceBundle;
522
+
523
+ import javafx.fxml.FXML;
524
+ import javafx.fxml.Initializable;
525
+ import javafx.scene.control.TextField;
526
+
527
+ public class bbb implements Initializable{
528
+
529
+ @Override
530
+ public void initialize(URL location, ResourceBundle resources){ }
531
+
532
+ @FXML
533
+ private static TextField textField;
534
+
535
+ }
536
+ ```
537
+
521
538
  bbb.fxml
522
539
  ```
523
540
  <?xml version="1.0" encoding="UTF-8"?>
@@ -527,10 +544,9 @@
527
544
  <?import javafx.scene.layout.*?>
528
545
  <?import javafx.scene.layout.AnchorPane?>
529
546
 
530
-
531
- <AnchorPane prefHeight="400.0" prefWidth="400.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8" fx:controller="application.bbb">
547
+ <AnchorPane prefHeight="400.0" prefWidth="400.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="application.bbb">
532
548
  <children>
533
- <TextField fx:id="textField" layoutX="126.0" layoutY="188.0" />
549
+ <TextField fx:id="textField" disable="true" editable="false" layoutX="126.0" layoutY="188.0" />
534
550
  </children>
535
551
  </AnchorPane>
536
552