实现Initializable接口,重写initialize方法,可以在视图加载时调用
@FXMLView("/fxml/main.fxml")
public class MainController extends AbstractFxmlView implements Initializable {
@Override
public void initialize(URL location, ResourceBundle resources) {
}
}
这个组件可以实现在javafx中加载web页面
@FXMLView("/fxml/main.fxml")
public class MainController extends AbstractFxmlView implements Initializable {
@FXML
private WebView webBox;
@Override
public void initialize(URL location, ResourceBundle resources) {
//获取引擎
WebEngine engine = webBox.getEngine();
//获取resources目录下editor中的index.html绝对路径
URL resource = getClass().getClassLoader().getResource("editor/index.html");
//引擎加载页面
engine.load(resource.toString());
}
}