How do I automate a Java Applet using the Java Access Bridge? - java

I need to automate a Java Applet which sits inside an IE only website. I know I can use the Java Access Bridge to interact with Java applications but I'm having trouble finding out how to hook it up to an Applet.
I am aware of a Java Bridge method called GetAccessibleContextFromHWND(..) which I thought I may be able to use. Unfortunately when I use Spy++ to try and get the Applet's HWND, I comes back blank so it seems this can not be done using the usual FindWindow(..) Windows API function.
How can I access and control Java Applets using the Java Access Bridge?

1.Find Applet tag from HTML page and get position(Height/Width) of it.
2.Move your cursor toward Applet center position with reference of IE window.
3.Use **getAccessibleContextAt** API and use Applet x,y position.
4.Get Accesiblecontext from above API.
5.Iterate to root level Accesiblecontext. Finally you will get first object of Applet window.

Related

How to implement a basic OS style console in java web client?

I'm currently planning on making a simple IRC style chat client and server system using Java for practice. I did some research into different ways of including the client functionality on a webpage like applets and java-web-start. I would like to have the client running on the users machine instead of the server itself. As I interpreted, out of the two, the applet pretty much does exactly that and seems way less effort to set up.
However, it turns out that applets have their own graphical implementation using "Graphics" class to render things like text, lines and shapes. Instead of going for something fancy, I would like to use a simple console interface like cmd on windows or shell on unix systems.
Is it possible to have this type of console running on a webpage as java applet or would I basically have to code the entire graphical look using the tools provided by the Graphics class? For this practice project, it would be ideal just using simple functionality provided in console windows like "nexInt()" and "system.out.print()" instead of having to add complex elements for input and output.
TL;DR:
Is it possible to embed an OS console within a webpage using java and what would be the preferred method of going about it?
Is it possible to embed an OS console within a webpage using java ..
AFAIU it is not possible to embed a console in a Swing or AWT desktop app. As far as embedding that into a web page, that would require an applet. Chrome and FF have completely removed support for applets and IE is set to follow.

Javascript connection with a java applet

I have a java applet with a main class at Eclipse IDE! I would like to call a function on a javascript. I have a variable for example x and i would like it to give it at the javascript and i want to receive another variable from the javascript for example y on my java applet.
Here is an example of how to invoke javascript from java Applet here and how to invoke java Applet from javascript here
Your question a little unclear about exact setup. So I give a couple answers:
If you have JavaScript function and want to execute function in Java, maybe this help: https://developer.mozilla.org/en-US/docs/Rhino
If you have JavaScript run in web browser and web browser also load applet, look here: http://docs.oracle.com/javase/tutorial/deployment/applet/invokingJavaScriptFromApplet.html
If you have Java Applet run in Eclipse IDE and JavaScript run in website in other location, you must make Applet provide HTTP(s) server and use XmlHttpRequest in JavaScript for call applet. For this you must use polling from JavaScript to Applet as Applet cannot call function on JavaScript this way, but JavaScript can connect to Applet.
If you have different setup from three mentioned here, please post and maybe we can find better answer.

Run Java Swing UI inside ActiveX Browser object

We have a "desktop" application written in Java Swing that currently uses Java Web Start to instantiate the app.
We have a need to run this application INSIDE an ActiveX Browser object.
Does anyone know if this is possible and, if so, how it could be done?
Thank you!
EDIT: is there any more information I could offer that might make this question more answerable?
You can try compiling the application with iKVM, basically making it a .NET application which should be able to run within an ActiveX component.
My Java ignorance is showing. It appears that starting in v6 you can run Swing Applications in a Java Applet inside a browser using the same basic jnlp setup (with minor changes) as the Web Start method. There are some security issues I have to work out moving to support v6, but once that is fixed we should be in business!

Taking a "screenshot" of a java applet

No. Not pressing PRT Screen. But here is what I want. And I need to know if it can be done and by what means :D
Okay so I have a java applet that runs and displays a walking man.
I need it so when I access a script (in some web scripting language) it takes a "screenshot" of that applet and then saves it on the server. Is this possible? and by what scripting means could I do it?
Thanks in advance!
If there are heavyweight components they might not come out, but the obvious way is:
Create a java.awt.image.BufferedImage
Call createGraphics to create a Graphics instance.
Call update(Graphics) on the applet.
Find a tutorial for converting the BufferedImage to a wire file format.
POST back to the web server.
You can use LiveConnect to connect both ways between Java and JavaScript. It's usually easy to add Java code to an applet simply by adding another reference to the archive attribute of the applet tag.
There are plenty of tutorials on the various parts. I've never done it myself.

Conversion of a Java Web Start app to an Applet

I'm trying to figure out how difficult it would be to convert a Java Web Start app to an applet. Theoretically, if the application didn't do anything such as write to the file system...basically if all of it's actions should be safe within the Applet sandbox, how tricky would it be? Is it a matter of wrapping the main app inside of an applet?
It should be quite straight forward. Simply create an applet class. From within the applet class you can instantiate whatever class JWS would normally start.
You then need to convert the JWS xml file to an applet tag and put it on a web page.

Categories