How to set UserAgent using WebEngine of JavaFX prior to JDK8? - java

I am using JDK7 for development and I want to set a user agent using JDK7 JavaFX Webengine.
Can anybody help me out with source code which sets the useragent using javaFX webengine using JDK7?
I have searched a lot but the only way is using JDK8 but I have to must use JDK7 to support Windows and MAC build.

Related

How to locate elements on Java Swing Application for accessibility?

I'm trying to locate elements on my Java swing application window using Accessibility Insights for Windows. But, it is not identifying my own java swing windows application. However, it is working fine when I'm trying to locate elements on any other Windows App like, Calculator.
How do I inspect my own java swing application, just like any other Window App ?
Java Swing application is not like other Windows apps. Swing uses its own GUI controls and engine which runs completely within Java. To Windows, a Swing application seems like a single canvas in the size of a window; in other words it does not use any Windows API for controls like buttons, labels etc. This is why you are not seeing anything.
If you want to make your Java program accessible, you should follow the Java Accessibility Guide:
for Java 16 (PDF, dated 2021-03, latest version)
for Java 11 (PDF, dated 2020-12, LTS version)
for Java 8 (LTS version)
for Java 7

Is there an equivalent to a private tab or private window in JavaFx WebEngine/WebView?

I have a project using JavaFX that would benefit from something like a private tab except for the WebEngine implementation. My use case is that the user may be accessing a web page with a WebEngine multiple times within a single instance of the application. I want each access to clear cookies, clear browsing history, clear cache, etc. just like a private browsing window would work in Chrome or Firefox. The application is a desktop application using AWT and Swing.
This question about WebView and cookies is very similar to the problems I'm attempting to solve. My thinking is that a full "private" browsing experience would just take care of not storing cookies and not caching without having to munge around with things like the CookieHandler.
This project is currently using JDK 8 using either the Oracle JDK or Coretto JDK. That does not preclude upgrading to a newer JDK if the features we want are available.
Is there a logical equivalent to a private tab in WebEngine or WebView?

Enabling Google Chrome Frame on DJ Native Swing

I have Google Chrome Frame installed on my Windows XP + IE8 machine.
When I navigate to chrome frame enabled page using IE8, it works.
But when I navigate to the site through a Java application that uses DJ Native Swing, the add-on is not activated.
The application uses SWT version 3.740.
Is it possible enable Chrome Frame in the DJ Native Swing browser?
Try imbedding WebKit layout engine with V8 JavaScript engine into Swing.
Getting Chrome Browser in java Applications
According to the documentation at JavaDoc: JWebBrowser it only supports IE and Mozilla:
A native web browser, using Internet Explorer or Mozilla on Windows, and Mozilla on other platforms.
However, according to the code it implements the "XULRunner Runtime" NSOption which according to The XULRunner Wikipedia article XULRunner appears in the credits for Chrome therefore it may suit your requirements to use Mozilla but it wont be Chrome.
The methods JWebBrowser.useWebkitRuntime() and JWebBrowser.useXULRunnerRuntime() seem to be the only built in options but you can use the NSOption class to define your own options if you know the correct variable names to pass.
I hope this helps
First, SWT control for Browser is what DJ Native Swing is using, but it also has all sorts of glue code to make it thread safe with Swing. Thus, changing to pure SWT would yield the same problems, plus threading issues to solve.
About Google Chrome Frame in SWT, and thus in DJ Native Swing, there is currently no support in SWT itself. See this bug:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=317322
SWT, and DJ Native Swing, allow to create one's own ActiveX bridge. Maybe you could create your own component for Google Chrome Frame ActiveX on windows, similar to what DJ Native Swing does for the Windows Media Player component.
Last time in Swing project when we had to integrate browser into Swing application, we finally used Eclipse SWT component, that defaulted to IE. That made build for Windows only, but it worked, and eliminated some Swing bugs.
Try using Eclipse SWT control for browser.

Integrate Google Chrome browser into eclipse

I am trying to create an application using SWT Browser. Is it possible to integrate Google Chrome as browser into Eclipse (not as external web browser)?
No, as of current stable release of google chrome, you cannot use it inside SWT. The reason is that google chrome (and essentially chromium) doesn't support ActiveX (like IE, Firefox, Safari etc) but is based on NPAPI. (Note: I am considering that you are working on Windows machine as you haven't mentioned in your question !!)
But there are projects which are trying to make an embeddable version of chromium. See these links:
Chromiumembedded
Is Google Chrome embeddable?
You can set it through Eclipse UI.
Goto : Window > Preferences > General > Web Browser
Select "Use External Browser" radio button
Click "New" button to add a new browser eg. Chrome !
Click Apply + Ok
... and you have it working !
Bug 405031 - [Browser] implement Chromium support
https://bugs.eclipse.org/bugs/show_bug.cgi?id=405031
If you can not make it through UI, Try to edit settings in the following file.
YOUR-WORKSPACE\.metadata\.plugins\org.eclipse.core.runtime\.settings there will be a file called org.eclipse.ui.browser.prefs open it with any text editor and change the appropriate values, It is self descriptive you can easily find out what to change and all. Have a back up of the same before you modify.
Hope this helps you.
EDIT: Restart your eclipse to effect the above change.
To integrate Chromium into Eclipse or SWT applications you can use https://github.com/equoplatform/chromium-swt.

Rendering webpages with WebKit in Java

Is it possible to render webpages with WebKit through a Java application?
P.S.
I want it to be compatible with Windows, Linux and Mac Os X.
Qt WebKit with Qt Jambi. Supports Windows, Linux and Mac.
In JavaFX is included in Java 7. This contains WebView which is based on WebKit.
http://docs.oracle.com/javafx/2/webview/jfxpub-webview.htm
WebKit via SWT
Also see
Previously answered question
and
jxBrowser

Categories