How do I call a Java applet from a button onclick? - java

I need to pass parameters between Java applet and Html by input data into textbox
and click button. Because it must input data and past to applet in the first place,
but how to slow down the applet ? I used to try using inner html , but it's failed.
Is there any idea for this question?

You could use netscape package. This documentation on this is found here. I have used this myself at times. Works on chrome, IE both windows and mac. Safari can also be tricked to work, but needs some workarounds.

Related

How to control IE-hosted java applet programmatically?

I've got a need to navigate java-applet programmatically and I am not that keen on Java platform. So lets assume I've got IE process stated with appropriate java applet loaded. Next I need to have some actions taken to this particular applet, like, lets say, sending WM_COMMAND to dialog along with BN_CLICKED code like I do with Windows in C. Assuming it's not a regular window I can refer to using HWND, I would like to ask someone for recommendations on how to do this.
As I understand you want to navigate (sending keystrokes and mouse clicks) a java-applet on the client side. It depends if you own the applet (say: you have the code and can change it) or if the applet is closed source and you just want to remote it.
In the first case use javascript to automate it. Change the containing HTML page to include some Javascript and pass parameters to the applet as described in the Java Tutorials.
If the applet accepts parameters, but you cannot change the HTML page, use a GreaseMonkey alternative for IE.
Your other approach (sending Windows Messages from an extern application to IE) should also work. Start Spy++ (use the 64bit version if you are using a 64bit Windows), choose "Search - Find window..." and drag the "Finder Tool" icon over the applet and release it. You will see then the HWND and if you press search you will see the window inside IE window hierarchy. So, yes you can send keystrokes and mouse clicks to a browser.
If I would automate the browser I would use Geb. You code a "web site test" in Groovy, just look at the Geb index page.
You could try to record a navigation through the applet with FireFox + "Selenium IDE" then export it and try run it in a Java Application with the Selenium IE WebDriver.
Information about Selenium can be found here : http://docs.seleniumhq.org/
Maybe this question will also help you : How to automate Java applet?

Capturing image from webcam

I'm trying to capture images by using webcam in an applet. The applet makes use of JMF. But I managed to run applet without actually installing JMF. I kept a button in HTML webpage so that when the button gets clicked, the applet should capture the image.
But for me it is giving a java.lang.RuntimeException: No permission to capture from applets. How can this exception be resolved so an applet can capture image using webcam in HTML page?
In order to capture images in an applet, it is necessary:
For you to digitally sign the code.
For the user to click "OK" when prompted to run the signed code.
If the functionality is being called from a button using JavaScript, wrap the Java code in one of the AccessController.doPrivileged(PrivilegedAction) variants.
AFAIR the installer for JMF does not have the 'allow capture from applets' checked by default. That needs to be reconfigured in the JMF options. I forget how.
Update
I dont want to give client package to extra overhead of the installation of JMF.
That is just silly.
The components of the JMF must be available on the run-time class-path of the applet, for it to function. If they are downloaded by the JRE using the applet element (or whatever), then the user has incurred that 'overhead'.
But perhaps you mean you don't want to make the end user run the installer that advises to 'reboot' at the end. In that case, you are missing my point while avoiding answering my question. That question, again, is "How did you get the DLL?".
Applets run with very limited permissions and that might be causing the issue.. Here is an old post which has information about signing an applet to get the necessary permissions..hope this helps
I think flash is a much better option. There are really easy solutions for that even using Javascript + Flash.
Take a look at this: http://www.xarg.org/project/jquery-webcam-plugin/
This question asked Too many times in this forum..
Anyways..Here is the solution: Java swing Program to capture webcam images
you have to modify it for applet which takes only 30 minutes

Insert text to a web browser and a Java application at the same time

I developing a Sinhala-English Unicode converter in java.Now I want to add the final output unicode sinhala word in facebook chat window while i typing them.If i type a word in application that letters also should print on facebook chat(Web browser's active window) window in any browser.I think the problem might be slightly unclear.But I expect any kind of answer for this problem...
Java has only one tool that allows emulation of user activity: java.awt.Robot. Using this class you can emulate mouse clicks and keyboard usage, so theoretically you can select browser window, then select text area on site and "type" any text you want. The problem with this solution is that current java API does not allow you to identify native window, so it is not easy to find the browser among the windows existing on user's desktop.
Finally, exactly as #Jonas said - better use Facebook API.

how to run Applets on Safari(web browser)

hii every one
good morning
I have created one project on JApplet
it runs successfully on Applet window
but i want to run it on web browsers(Internet explorer , Mozilla firefox, Safari, etc.)
I m using Mac os x and i want to run it on Safari.
You have to create an html which refers to the applet. Open the html in browser.
Take a look here for the applet tag http://www.w3schools.com/TAGS/tag_applet.asp
Using Mac OS X, in /Applications/Utilities you'll find Java Preferences.app. In the Advanced tab, you can enable the Java Console, which may tell you more about what's wrong when you open your HTML page in a browser.
Also, you can edit your question to add code, etc.
Addendum: You might want to start with a known working example.

Testing onbeforeunload events from Selenium

I'm trying to write a Selenium test for a web page that uses an onbeforeunload event to prompt the user before leaving. Selenium doesn't seem to recognize the confirmation dialog that comes up, or to provide a way to hit OK or Cancel. Is there any way to do this? I'm using the Java Selenium driver, if that's relevant.
You could write a user extension (or just some JavaScript in a storeEval etc) that tests that window.onbeforeunload is set, and then replaces it with null before continuing on from the page. Ugly, but ought to get you off the page.
I've just had to do this for an application of mine where the onbeforeunload handler brings up a prompt if a user leaves a page while a document is in an unsaved state. Python code:
driver.switch_to.alert.accept()
The Java equivalent would be:
driver.switchTo().alert().accept();
If the alert does not exist, the code above will fail with a NoAlertPresentException so there is no need for a separate test to check the existence before accepting the prompt.
I'm running Selenium 2.43.0 but I think this has been doable for a while now.
In cases where I don't want the prompt to come up at all because that's not what I'm testing, I run custom JavaScript in the browser to set window.onbeforeunload to null before leaving the page. I put this in the test teardown code.
faced same problem with "beforeunlaod" event listner, LUMINUS! a chrome addon that helps me just block the event listener in the plugin thats all..
When I was confronted with limited control which I had over browser using Selenium, I turned to MozLab plugin which solved my problem if only for one browser platform.

Categories

Resources