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.
i want to call a method startApp() ,located in the java applet file from a java script file.
i tried the following method
<APPLET name="drops" code="BigDrops.class" width=700 height=650 ></APPLET>
document.drops.startApp();
but it shows "has no method startApp()" when i looked in the console of the browser
But the strange fact i noticed is that this problem is occured in all computers except mine..the files are loaded in the dropbox.
When i run the applet using the dropbox url from my computer, it works fine
tell me why it does not work and also give the solution
LiveConnect calls from JavaScript are limited under some security level from 7u21 and 7u25.
I have a program allowing script files to "compete" with each other in a games such as Tic Tac Toe .
The visualization is made in the console and looks something like this:
| XO |
| OX O|
| X |
- X is the winner! Meh..
Not very exciting.
I was thinking of making a Swing visualisation, but after seeing a presentation on the Raphaƫl JavaScript vector graphics library I decided that I'd be cool to make the visualization browser based, even though every thing will be running on the same computer.
Do I need a full fledged web server to accommodate for this? How does the JavaScript communicate with the Java program?
Building a Swing interface would be the most straightforward solution, but this would probably be the messiest one as well.
The web browser solution is probably the most satisfying if you already have a web server going, but has a lot of overhead to set up and properly understand. Then again, you have layers of different technology to play with and get confused in (java, JSP, HTML, javascript, css, etc).
These days, with HTML5 and available javascript libraries, the web interface is in my opinion the best choice for most interfaces, so you might as well set up your machine and have it available for the next project.
Any communication between the server (Java) and the browser will take place with a HTTP request from the browser.
This may happen in two ways:
a) By pressing a submit button on a browser HTML page and rendering a HTML page on the server as a response (usually through server side scripting like JSP, although you could generate the entire page through java code)
b) By using Ajax in javascript to make an asynchronous call to the server, which will respond with data that you can then interpret and render with javascript (probably the best solution for what you are trying to do). There are many ready javascript libraries to help you with this, including jQuery.
In method b, you would essentially be waiting on the server side for a post from the browser and then you would be responding with a page written in XML, json or even pure text. Your javascript code would then interpret the data and render it on the browser HTML page (which you will have loaded at the starting point for the application).
Do I need a full fledged web server to accommodate for this? How does the JavaScript communicate with the Java program?
If you're going to host the JavaScript and display in a browser, then yes, the browser would need to be able to request the data from the Java via an HTTP request. Although browsers can load data via file:/// URIs, it's (quite) awkward to handle those requests dynamically.
It's trivial to install a web server, though. Tomcat is easy to install, and there are several other options if you prefer, such as TJWS (no relation), Winstone, LiteWebServer, Jetty...
If you're forced to run Java for the game engine I would suggest using Jetty to give you the ability to service HTTP request from a browser. It's all embeddd in your application and there's no faffing with having to package your app as a WAR and deploy it everytime you make a change.
[edit]
Just read about Tiny Java Web Sever which could also be an alternative to Jetty if you need a smaller footprint.
Javascript can communicate with a Java applet on the page (at least in theory). A Java applet is going to throw up a warning when it loads, and requires that Java be installed on the machine.
Yes a webserver will be necessary. Javascript will probably run as part of an html form. If any Java side processing is required, then web server is necessary. Since it is not possible for the html/javascript to communicate with a standalone java program. But Why need a java server side program at all? Can the logic not be written in java script totally?
I am new in JavaScript. I want to know how to call a simple method in Java file from JavaScript program. Could you please give me a simple example as well?
Thank you
Javascript will not be able to access server side java code directly.
It will need to make an ajax call to access a method or make a http call.
If you have applets you will be able to access the applet java code.
See example here
http://download.oracle.com/javase/1.5.0/docs/guide/plugin/developer_guide/js_java.html
When you say "java file" I presume you mean a Java applet. In that case, say you have this applet code on your page:
<applet id="myapplet" class="MyApplet.class" ... />
If you wanted to call the helloWorld() method in that applet, you simply need to do this:
<script type="text/javascript>
document.getElementById['myapplet'].helloWorld();
</script>
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.