没有在BorderPane

时间:2018-01-06 18:37:13

标签: javafx jxbrowser

这是代码。我没有在VBox中看到jxBrowser。它创建它但不显示它。有谁知道为什么会这样?允许JxBrowser像这样嵌套吗?     VBox liveStream = new VBox();     liveStream.setSpacing(10);

//HBox Creation
HBox urlTextHolder = new HBox();
urlTextHolder.setSpacing(10);
urlTextHolder.setPadding(new Insets(1,5,5,5));

//Text Field and Button Creation (Removed this code because it is not relevant)

Browser browser = new Browser();
BrowserView browserView = new BrowserView(browser);
browser.loadHTML("<html><body><h1>Hello World!</h1></body></html>");


urlTextHolder.getChildren().addAll(url, urlSubmit);
liveStream.getChildren().addAll(urlTextHolder, browserView);
main.setLeft(liveStream);

//Scene WindowbrowserView

Scene scene = new Scene(main, 1920, 1080, Color.WHITE);
Stage mainPage= new Stage();
mainPage.setTitle("ILEC Live Stream Viewing");
mainPage.setScene(scene);
mainPage.show();

1 个答案:

答案 0 :(得分:1)

You should build your JavaFX layout correctly. JavaFX BrowserView extends the StackPane. Therefore, if you invoke following code:

liveStream.getChildren().addAll(urlTextHolder, browserView);
VBox.setVgrow(browserView, Priority.ALWAYS);

and add the livestream instance to the center of the main:

BorderPane main = new BorderPane(liveStream);

the browser content should be successfully displayed.