Java 9 makes internal classes inaccessible, so setting the page background is no longer supported: package com.sun.webkit is declared in module javafx.web, which does not export it

This commit is contained in:
Reinhard Pointner 2017-10-16 22:31:21 +02:00
parent 32e835c3b6
commit e3a1269de1

View File

@ -1,14 +1,11 @@
package net.filebot.ui; package net.filebot.ui;
import static net.filebot.Logging.*;
import static net.filebot.Settings.*; import static net.filebot.Settings.*;
import static net.filebot.util.ui.SwingUI.*; import static net.filebot.util.ui.SwingUI.*;
import java.lang.reflect.Field;
import java.net.URL; import java.net.URL;
import java.util.Locale; import java.util.Locale;
import java.util.Optional; import java.util.Optional;
import java.util.logging.Level;
import javafx.animation.Interpolator; import javafx.animation.Interpolator;
import javafx.animation.KeyFrame; import javafx.animation.KeyFrame;
@ -115,15 +112,18 @@ public class GettingStartedStage {
} }
protected void setBackground(WebEngine engine, int color) { protected void setBackground(WebEngine engine, int color) {
try { /*
// use reflection to retrieve the WebEngine's private 'page' field * Java 9 makes internal classes inaccessible, so setting the page background is no longer supported: package com.sun.webkit is declared in module javafx.web, which does not export it
Field f = engine.getClass().getDeclaredField("page"); */
f.setAccessible(true); // try {
com.sun.webkit.WebPage page = (com.sun.webkit.WebPage) f.get(engine); // // use reflection to retrieve the WebEngine's private 'page' field
page.setBackgroundColor(color); // Field f = engine.getClass().getDeclaredField("page");
} catch (Exception e) { // f.setAccessible(true);
debug.log(Level.WARNING, "Failed to set background", e); // com.sun.webkit.WebPage page = (com.sun.webkit.WebPage) f.get(engine);
} // page.setBackgroundColor(color);
// } catch (Exception e) {
// debug.log(Level.WARNING, "Failed to set background", e);
// }
} }
protected WebEngine onPopup(WebView webview) { protected WebEngine onPopup(WebView webview) {