翻譯|產(chǎn)品更新|編輯:李顯亮|2019-08-16 10:55:21.193|閱讀 690 次
概述:JxBrowser更新至最新版v7.1,引入了BytesReceived允許獲取有關(guān)從網(wǎng)絡(luò)接收的字節(jié)數(shù)的信息,允許使用部分回調(diào)將鼠標(biāo)和鍵盤事件發(fā)送到網(wǎng)頁之前攔截,改進(jìn)多種功能,修復(fù)多項Bug,我們一起來看一看新功能詳解吧!
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
JxBrowser是將基于Chromium的瀏覽器與Java應(yīng)用程序集成,以處理和顯示HTML5,CSS3,JavaScript,F(xiàn)lash等。
JxBrowser更新至最新版v7.1,引入了BytesReceived允許獲取有關(guān)從網(wǎng)絡(luò)接收的字節(jié)數(shù)的信息,允許使用部分回調(diào)將鼠標(biāo)和鍵盤事件發(fā)送到網(wǎng)頁之前攔截,改進(jìn)多種功能,修復(fù)多項Bug,我們一起來看一看新功能詳解吧!>>歡迎下載JxBrowser v7.1體驗
新增功能
以下示例演示如何抑制鼠標(biāo)滾輪,可以使用這些回調(diào)來獲取有關(guān)鼠標(biāo)和鍵盤事件的通知,以便在應(yīng)用程序中實現(xiàn)熱鍵。
browser.set(MoveMouseWheelCallback.class, params -> Response.suppress());
以下示例演示如何獲取位圖,將其轉(zhuǎn)換為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();
以下示例演示了如何執(zhí)行此操作:
browser.devTools().remoteDebuggingUrl().ifPresent(url -> {});
以下示例演示如何在可用設(shè)備列表中選擇第一個設(shè)備:
engine.mediaDevices().set(SelectMediaDeviceCallback.class, params -> Response.select(params.mediaDevices().get(0)));
如果您想禁止網(wǎng)頁訪問您的麥克風(fēng)或網(wǎng)絡(luò)攝像頭,您可以使用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 -> {});
改進(jìn)
Bug修復(fù)
*想要購買正版授權(quán)的朋友可以哦~
掃描關(guān)注“慧聚IT”微信公眾號,及時獲取更多產(chǎn)品最新動態(tài)及最新資訊
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@fc6vip.cn