翻譯|產品更新|編輯:李顯亮|2019-08-16 10:55:21.193|閱讀 690 次
概述:JxBrowser更新至最新版v7.1,引入了BytesReceived允許獲取有關從網絡接收的字節數的信息,允許使用部分回調將鼠標和鍵盤事件發送到網頁之前攔截,改進多種功能,修復多項Bug,我們一起來看一看新功能詳解吧!
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
JxBrowser是將基于Chromium的瀏覽器與Java應用程序集成,以處理和顯示HTML5,CSS3,JavaScript,Flash等。
JxBrowser更新至最新版v7.1,引入了BytesReceived允許獲取有關從網絡接收的字節數的信息,允許使用部分回調將鼠標和鍵盤事件發送到網頁之前攔截,改進多種功能,修復多項Bug,我們一起來看一看新功能詳解吧!>>歡迎下載JxBrowser v7.1體驗
新增功能
以下示例演示如何抑制鼠標滾輪,可以使用這些回調來獲取有關鼠標和鍵盤事件的通知,以便在應用程序中實現熱鍵。
browser.set(MoveMouseWheelCallback.class, params -> Response.suppress());
以下示例演示如何獲取位圖,將其轉換為Java AWT和JavaFX圖像,并將其保存為PNG文件:(Swing和JavaFX)
// Creating and running Chromium engine Engine engine = Engine.newInstance( EngineOptions.newBuilder(HARDWARE_ACCELERATED).build()); Browser browser = engine.newBrowser(); // Resize browser to the required dimension browser.resize(500, 500); // Load the required web page and wait until it is loaded completely browser.navigation().loadUrlAndWait("//www.google.com"); // Take a bitmap of the currently loaded web page. Its size will be // equal to the current browser's size. Bitmap bitmap = browser.bitmap(); // Convert the bitmap to javafx.scene.image.Image Image image = BitmapUtil.toImage(bitmap); // Convert javafx.scene.image.Image to java.awt.image.BufferedImage BufferedImage bufferedImage = SwingFXUtils.fromFXImage(image, null); // Save the image to a PNG file ImageIO.write(bufferedImage, "PNG", new File("bitmap.png"));
// Creating and running Chromium engine Engine engine = Engine.newInstance( EngineOptions.newBuilder(HARDWARE_ACCELERATED).build()); Browser browser = engine.newBrowser(); // Resize browser to the required dimension browser.resize(500, 500); // Load the required web page and wait until it is loaded completely browser.navigation().loadUrlAndWait("//www.google.com"); // Take a bitmap of the currently loaded web page. Its size will be // equal to the current browser's size. Bitmap bitmap = browser.bitmap(); // Convert the bitmap to javafx.scene.image.Image Image image = BitmapUtil.toImage(bitmap); // Convert javafx.scene.image.Image to java.awt.image.BufferedImage BufferedImage bufferedImage = SwingFXUtils.fromFXImage(image, null); // Save the image to a PNG file ImageIO.write(bufferedImage, "PNG", new File("bitmap.png"));
WebStorage localStorage = frame.localStorage(); localStorage.putItem("car", "BMW"); localStorage.clear();
以下示例演示了如何執行此操作:
browser.devTools().remoteDebuggingUrl().ifPresent(url -> {});
以下示例演示如何在可用設備列表中選擇第一個設備:
engine.mediaDevices().set(SelectMediaDeviceCallback.class, params -> Response.select(params.mediaDevices().get(0)));
如果您想禁止網頁訪問您的麥克風或網絡攝像頭,您可以使用RequestPermissionCallback如下所示:
engine.permissions().set(RequestPermissionCallback.class, (params, tell) -> { PermissionType type = params.permissionType(); if (type == PermissionType.VIDEO_CAPTURE || type == PermissionType.AUDIO_CAPTURE) { tell.deny(); } else { tell.grant(); } });
network.on(ResponseBytesReceived.class, event -> { byte[] data = event.data(); });
browser.settings().hideScrollbars();
Engine engine = Engine.newInstance( EngineOptions.newBuilder(renderingMode) .disableTouchMenu() .build());
browser.on(FocusRequested.class, event -> {});
改進
Bug修復
*想要購買正版授權的朋友可以哦~
掃描關注“慧聚IT”微信公眾號,及時獲取更多產品最新動態及最新資訊
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn