2016-06-15 124 views
2

我正在評估JxBrowser 6.4作爲我們應用程序的瀏覽器引擎。我們需要我們的軟件來處理Window和OSX。當我嘗試運行JxBrowser 6的javafx示例時,它只是掛起(不顯示窗口)。沒有任何例外,應用程序只是掛起沒有任何用戶界面。JxBrowser 6掛在osx el capitan

下面的代碼(從jxbrowser文檔複製粘貼):

import com.teamdev.jxbrowser.chromium.Browser; 
import com.teamdev.jxbrowser.chromium.javafx.BrowserView; 

import javafx.application.Application; 
import javafx.scene.Scene; 
import javafx.scene.layout.StackPane; 
import javafx.stage.Stage; 

public class JfxView extends Application { 
    @Override 
    public void start(Stage primaryStage) { 
     Browser browser = new Browser(); 
     BrowserView browserView = new BrowserView(browser); 

     StackPane pane = new StackPane(); 
     pane.getChildren().add(browserView); 
     Scene scene = new Scene(pane, 400, 300); 
     primaryStage.setScene(scene); 
     primaryStage.show(); 

     browser.loadHTML("<html><body><h1>Hello world!</h1></body></html>"); 
    } 

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

最後幾個日誌如下:

JxBrowser license valid. 
08:10:02 INFO: OS name: Mac OS X 
08:10:02 INFO: JRE version: 1.8.0_65 64-bit 
08:10:02 INFO: JxBrowser version: 6.4 
08:10:02 INFO: JxBrowser type: HEAVYWEIGHT 
08:10:02 INFO: Starting IPC... 
08:10:02 INFO: Starting IPC Server... 
08:10:02 INFO: Starting socket server 
08:10:02 INFO: Starting socket server at port 1101... 
08:10:02 INFO: Starting IPC Process... 

擺動例如工作正常,並在同一代碼運行完美罰款在窗戶上。

回答

1

請使用JxBrowser文檔page中的示例來描述如何在JavaFX應用程序中使用JxBrowser。例如:

import com.teamdev.jxbrowser.chromium.Browser; 
import com.teamdev.jxbrowser.chromium.BrowserCore; 
import com.teamdev.jxbrowser.chromium.internal.Environment; 
import com.teamdev.jxbrowser.chromium.javafx.BrowserView; 
import javafx.application.Application; 
import javafx.scene.Scene; 
import javafx.scene.layout.BorderPane; 
import javafx.stage.Stage; 

/** 
* Demonstrates how to embed Browser instance into JavaFX application. 
*/ 
public class JavaFXSample extends Application { 

    @Override 
    public void init() throws Exception { 
     // On Mac OS X Chromium engine must be initialized in non-UI thread. 
     if (Environment.isMac()) { 
      BrowserCore.initialize(); 
     } 
    } 

    @Override 
    public void start(final Stage primaryStage) { 
     Browser browser = new Browser(); 
     BrowserView view = new BrowserView(browser); 

     Scene scene = new Scene(new BorderPane(view), 700, 500); 
     primaryStage.setScene(scene); 
     primaryStage.show(); 

     browser.loadURL("http://www.google.com"); 
    } 

    public static void main(String[] args) { 
     launch(args); 
    } 
} 
相關問題