1

I am trying to open webpage in another webview by using following code. In this program i am using two webview in one test1.htm is displayed and i want on clicking the hyperlink in first webview the new page should open in another webview

class webcontrol extends JFrame
{

    webcontrol()
    {
        setLayout(null);
        Container cp=this.getContentPane();
        fxpanel= new JFXPanel();
        add(fxpanel);
        fxpanel.setBounds(660, 0, 230, screenSize.height-120);

        Platform.runLater(new Runnable() {
            public void run()
            {
                initFx(fxpanel,fxpanel1);
            }
        }
   );


 }

 private static void initFx(final JFXPanel fxpanel, JFXPanel fxpanel1)
 { 
     WebView webview=null,webview1=null;
     WebEngine eng=null,eng1=null; 
     Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();

     Group group1= new Group();
     Scene scene1= new Scene(group1);
     fxpanel1.setScene(scene1);    

     webview1 = new WebView ();
     group1.getChildren().removeAll();
     group1.getChildren().add(webview1);

     Group group= new Group();
     Scene scene= new Scene(group);
     fxpanel.setScene(scene);    
     webview = new WebView ();
     group.getChildren().removeAll();

     group.getChildren().add(webview);


     eng= webview.getEngine();
     eng1=webview1.getEngine();
     File htmlFile = new File("d:/newfolder/test.htm");
     File htmlFile1 = new File("d:/newfolder/test1.htm");
     try
     {
         eng.load(htmlFile.toURI().toURL().toString());
         eng1.load(htmlFile1.toURI().toURL().toString());
     }
     catch(Exception ex)
     {
         ex.printStackTrace();
     }
 }


         }
4

1 回答 1

0

没有关闭字符串:

("d:/newfolder/test1.htm);

然而

("d:/newfolder/test.htm");

很好。

于 2012-12-24T18:02:26.840 回答