-1

In my JFrame pane I wanna dislay a webview, the decare of class is :

public class MainTabbedForm extends javax.swing.JFrame {

I have added a Button named Display Weband here is the code of this :

        private void siteSurveyActionPerformed(java.awt.event.ActionEvent evt) {                                           
JFrame myFrame = new JFrame();
JFXPanel myFXPanel = new JFXPanel();
myFrame.add(myFXPanel);    
  Platform.runLater(() -> {
      BorderPane borderPane = new BorderPane();
      WebView webComponent = new WebView();

      webComponent.getEngine().load("http://google.com/");

      borderPane.setCenter(webComponent);
      Scene scene = new Scene(borderPane,450,450);
      myFXPanel.setScene(scene);
});

    }      

But when I run the program and press the Display Web Button it does nothing! And nothing in Netbeans output displaye, No error or anything. Where I am doing wrong?

M. Martin
  • 673
  • 1
  • 13
  • 23
me_the_seven
  • 111
  • 12

1 Answers1

2

You are missing

myFrame.setVisible(true);
James_D
  • 201,275
  • 16
  • 291
  • 322
  • Thanks sir, And I have another question, I wanna ask it, but before wanna know. My Webview is displaying a page that is on my local host. And it need authentication. (When I go to that page in browser, browser wants the user and password, so when I run it from java,webview displays 401 Unauthorized, Is it possible to display it? – me_the_seven Jun 06 '17 at 09:23
  • @me_the_seven: That's new question; look for [`HttpClient`](https://stackoverflow.com/search?tab=votes&q=%5bswing%5d%20HttpClient). – trashgod Jun 06 '17 at 09:41
  • @trashgod I just asked https://stackoverflow.com/questions/44387512/display-webview-with-authentication-inside-program – me_the_seven Jun 06 '17 at 10:27
  • @James_D congratz on reaching >100k – mKorbel Jun 07 '17 at 12:16
  • @mKorbel Thanks. You too :). – James_D Jun 07 '17 at 12:57