2017-11-20 1 views
0
에서 TextFlow의에 텍스트를 얻을 수

컨트롤러 :은 어떻게 TextField를 초기화하고 자바 FX

package sample; 

import javafx.event.*; 
import javafx.fxml.FXML; 
import javafx.scene.text.Text; 
import javafx.scene.text.TextFlow; 
import javafx.scene.control.TextField; 

public class Controller { 
    @FXML TextFlow textFlow; 
    @FXML TextField textField = new TextField(); 

    public void click(ActionEvent event){ 
     System.out.print(textField.getText()); 
     Text text = new Text("Text from textField"); 
     textFlow.getChildren().add(text); 
    } 
} 
내가 텍스트 필드에서 텍스트를 얻을 TextFlow의에 인쇄 할 수 있도록하려면

enter image description here

. 나는 Java를 처음 사용하고 일부 검색을 수행했습니다. 어떻게해야합니까?

답변

-1

일부 구성 요소에 ActionListener를 작성하고 수행

String text = textField.getText(); 

textFlow.getChildren().addAll(text); 
+0

방법 및 addAll (java.lang의, 문자열) –

+0

미안 해요, 내가 추가 한 텍스트 텍스트 = 새로운 텍스트를 확인할 수 없습니다 (textField.getText()); –