user interface - JavaFX textarea doesn't display changed value -


hello guys i'm using jdk 1.8 netbeans version 8 , scenebuilder 2.2. have files main.fxml , maincontroller have 2 tabs , textarea @ bottom supposed print out status info.

login.fxml tab attached main.fxml first tab through include in scenebuilder. has own controllers , button need print info textarea in maincontroller. can access textarea fxmlloader , change value doesn't update in ui. let's @fxml logid textarea in maincontroller , code in logincontroller:

@fxml private button btn;

@override public void initialize(url url, resourcebundle rb) {      btn.setonaction(new eventhandler<actionevent>() {          @override         public void handle(actionevent event) {             try {                 fxmlloader fxmlloader = new fxmlloader();                 fxmlloader.setlocation(getclass().getresource("main.fxml"));                 anchorpane pane = fxmlloader.load();                 maincontroller control = (maincontroller) fxmlloader.getcontroller();                  new thread(new runnable() {                      @override                     public void run() {                         platform.runlater(new runnable() {                              @override                             public void run() {                                 control.logid.appendtext("hello");                                 system.out.println(control.logid.gettext());                                  //prints "hello" in console not ui                             }                         });                     }                 }).start();             } catch (ioexception ex) {                 logger.getlogger(logincontroller.class.getname()).log(level.severe, null, ex);             }         }     }); }    

any appreciated.

after week of trying can came different solution. update without using fxmlloader();

all did give login.fxml anchorpane fx:id , kept printing getparent() console until got root so.. @fxml anchorpane paneid; // in logincontroller.java

//in platform.runlater ran bottom code

textarea area = (textarea) paneid.getparent().getparent().getparent().lookup("#logid"); area.appendtext("hello\n");

first getparent tab content area

second tabpane

third main anchorpane


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -