0

我有一个由 SceneBuilder 生成的 JavaFX 接口......所以我在 sample.fxml 中有我的视图组件。当我启动应用程序时,它看起来像这样:http://i.imgur.com/3tj0tN9.png 在那个蓝色窗格中,我想添加浏览器(使用 JxBrowser 库),所以我这样做了:

 public void loadMap(ActionEvent actionEvent) {
    initComponents(); //setting my buttons visibility

    Browser browser = new Browser();
    BrowserView browserView = new BrowserView(browser);
    gamePane.getChildren().add(browserView);
    browser.loadURL("http://www.google.com");

    gamePane.getChildren().add(new Button("random"));
}

这是我的主要内容:

public class Main extends Application {

@Override
public void start(Stage primaryStage) throws Exception{
    Parent root = FXMLLoader.load(getClass().getResource("sample.fxml"));
    primaryStage.setTitle("Google Maps ");
    primaryStage.setScene(new Scene(root));
    primaryStage.show();
}


public static void main(String[] args) {
    launch(args);
}

}

该按钮已添加,但我的浏览器不会出现..我能做什么?我在 Swing 中使用过它并且它有效,但这里似乎没有。浏览器已加载(因为我在控制台中收到特定消息)但未显示。

4

0 回答 0