Inside of my JPanel, I have a button calling SimpleBrowser
JButton swingButton = new JButton();
swingButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
SimpleBrowser openBrowser = new SimpleBrowser();
openBrowser.main((new String[0]));
}
});
swingButton.setText("Browser");
add(swingButton, BorderLayout.SOUTH);
this is my SimpleBrowser class
public class SimpleBrowser extends Application {
VBox vb = new VBox();
public void main(String[] args) {
Application.launch(args);
}
@Override
public void start(Stage primaryStage) {
vb.setId("root");
WebView browser = new WebView();
WebEngine engine = browser.getEngine();
String url = "https://www.google.com";
engine.load(url);
vb.getChildren().addAll(browser);
Scene scene = new Scene(vb);
primaryStage.setScene(scene);
primaryStage.show();
}
When I run this code, JButton opens up properly SimpleBrowser and display google. However, when I close this application and repress JButton, nothing happens. It suppose to relaunch SimpleBrowser and display google.
Could you guys help me?