SWT webkitbrowser and javascript - java

I am using the WebkitBrowser to run a browser app like on my desktop. I want to know it's possible for the WebkitBrowser widget to listen for javascript calls made when the user interacts with the browser applications' buttons.
I don't know if this will help but I am building the browser app with Ext GWT.

I'm not so familiar with WebkitBrowser, but it looks like at the very least you could use a StatusTextListener to listen for changes in the status bar text and have Javascript modify that by editing the window.status field.
Also, I don't know how attached you are to WebkitBrowser, but the standard SWT Browser widget does support Javascript to Java communication through the BrowserFunction object.
Here's an example of using the BrowserFunction class from SWT snippets:
http://dev.eclipse.org/viewcvs/viewvc.cgi/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet307.java?view=co

Related

Interacting with a webview (JAVA ANDROID)

In my app I have a webview to show the user some information from a web page. Before seeing the info though, you have to choose an option on a dropdown list on the webpage. Is there any way I can choose the right option for the user (via code) and only have them see the content?
You can run arbitrary javascript inside a WebView, initiated from Java. Be sure you have javascript enabled. Once you've done that,
theWebView.loadUrl( "javascript:alert('Hello')" );
is the mechanism to invoke javascript functions or scripts. To pre-select a drop-down, you may want to include jquery or such, making the selection easier.

Browser window control focus

I'm working on a web app that interfaces with TWAIN devices (document scanners). JavaScript sets a Java applet's boolean that triggers it to pull up the scanner interface. When the TWAIN interface is shown it is sometimes behind the browser window. It sounds like there's no way to set the TWAIN window visible, so instead I need to send the browser window backwards to be behind it. I have tried JavaScript window.blur() and also Java setVisible(false) in my applet and neither seem to work. Keep in mind I don't have any popup windows, the applet is embedded in the only browser window. I have read that JNI is capable of this but cannot find any examples. I am capable of using JNI because my applet is signed, although I'd prefer a JavaScript solution as it would be easier to implement.

SWT listener for JavaScript window.resizeTo?

I'm working on an application that uses the SWT Browser widget to display an HTML page with some JavaScript in it. The JavaScript tries to use window.resizeTo to change the size of the window, but it currently isn't having any effect.
I've fiddled with the browser settings, and it doesn't seem to be an issue with the underlying browser; switching between Mozilla and Internet Explorer rendering engines has no effect. I suspect that SWT simply doesn't automatically re-size the window in response to JavaScript functions.
I can easily re-size the window from my Java code, but I need to know when to re-size it, and how big JavaScript wants it to be. Does SWT provide a way to listen for this? If so, how?
I still don't know of any way to get this information, but a work-around is to change SWT versions. Some of them implement JavaScript's window.resizeTo automatically, and some of them do not.

Javascript PopUp Functionality

I spent hundreds of hours writing an HTML5 application.This application deals with multiple popups and I suddenly ran into a problem when managing them.
My main goal would be bring a blurred popup window to front by focusing it.I am wondering if this is possible in JavaScript.
If not, could I use java applet in order to gain more functionality on my popup windows. Could I perhaps embed Google V8’s engine in order to render my existing HTML5 code in this application?
when you open a window you create a reference to it. You can then use that reference to call focus() on.
var foo = window.open( /*params*/ );
foo.focus();

Objective-C/Java interaction

I have some java code that I use on a windows machine that runs as a service and has a tray icon that I want to port to Mac OS X. From what I can tell there is no good way to make a menu bar icon using java, so I want to basically wrap my java code with objective-c so I can have a nice menu bar icon and still interact with the java code as I am able to when running the code on my windows box. Is there a good way to do this?
My java code makes web requests every so often so the main functionality I'm looking for is to start/stop the web client, as well as receive updates from the java code on the status of the web requests (more or less push notifications).
Thanks for your help everyone!
If all you're trying to do is get your application's icon displayed in the Dock & the Finder, you don't need to write an objective-C wrapper; all you need to do is bundle the Java code up in with the icons in an OS X "application bundle". See Apple's Java Deployment Guide
You might also want to look into the com.apple.eawt package (see questions/1319805/java-os-x-dock-menu), which provides some features to allow a Java app to appear more like a native OS X application to the user (for example, supporting drag-and-dropping a file to the application icon).

Categories