title: How does the javafx fxml method add active visible events to the current interface?
body: <p>There is a tabPane tab, which has two panels, A and B, which are created by fxml. When the program starts, it will call the initialize() method to initialize it. The function I will implement is placed in the method. But I can't realize my needs. The effect I want to achieve is that when the program is started, when I click interface B, an event is triggered, that is, the B interface. When the activation is visible, a certain method is executed.</p>
  
  <pre><code>public class TestLogPane extends AnchorPane implements Initializable {
  
      @Override
      public void initialize(URL location, ResourceBundle resources) {
              webView.getEngine().load("https://wwww.xxx.com/member/login.jhtml");
              webView.getEngine().getLoadWorker().stateProperty()
                      .addListener((obs, oldValue, newValue) -&gt; {
                          if (newValue == Worker.State.SUCCEEDED) {
                              if (webView.getEngine().getLocation().contains("item.taobao.com")) {
                                 System.out.println(webView.getEngine().getLocation());
                              }
                          }
                      });
      }
  
  }
  
  &lt;TestLogPane fx:id="anchorPane" prefHeight="814.0" prefWidth="1414.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.fendo.huasheng.component.pane.TestLogPane"&gt;
     &lt;children&gt;
        &lt;WebView fx:id="webView" prefHeight="814.0" prefWidth="1414.0" /&gt;
        &lt;Button layoutX="1043.0" layoutY="22.0" onAction="#onGet" mnemonicParsing="false" prefHeight="48.0" prefWidth="80.0" text="Go" /&gt;
        &lt;Button layoutX="980.0" layoutY="22.0" onAction="#onLoad" mnemonicParsing="false" prefHeight="48.0" prefWidth="80.0" text="Load" /&gt;
     &lt;/children&gt;
  &lt;/TestLogPane&gt;
  </code></pre>
  
  <p>Tabpane fxml is defined as follows</p>
  
  <pre><code>&lt;HomePane xmlns="http://javafx.com/javafx"
            xmlns:fx="http://javafx.com/fxml"
            fx:controller="com.fendo.huasheng.component.pane.HomePane"
            prefHeight="800.0" prefWidth="1024.0"&gt;
      &lt;fx:define&gt;
          &lt;fx:include source="TestLogPane.fxml" fx:id="testLogPane" /&gt;
          &lt;fx:include source="xxxx.fxml" fx:id="xxxx" /&gt;
      &lt;/fx:define&gt;
      &lt;children&gt;
          &lt;BorderPane prefHeight="750.0" prefWidth="900.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="2.0"&gt;
              &lt;center&gt;
                  &lt;TabPane prefHeight="750.0" prefWidth="757.0"  BorderPane.alignment="CENTER"&gt;
                      &lt;tabs&gt;
                          &lt;Tab text="xxxx" content="$xxxx"&gt;&lt;/Tab&gt;
                          &lt;Tab text="Taobao" content="$testLogPane"&gt;&lt;/Tab&gt;
                      &lt;/tabs&gt;
                  &lt;/TabPane&gt;
              &lt;/center&gt;
          &lt;/BorderPane&gt;
      &lt;/children&gt;
  &lt;/HomePane&gt;
  </code></pre>