Drag and drop from browser to Java application - java

I am working on a Java application that has the ability to accept text (in a JTextComponent) that is selected, dragged and dropped from a browser such as Chrome and IE.
Is it possible for my application to know the URL of the text I am dragging and dropping?
In other words, does the export of data from the browser contain the URL along with the highlighted text that I am dragging and would it be possible for me to access this URL in my Java application?
I know this is likely based on which browser I am using. I am just curious if this is a possibility in any of the common browsers (Chrome, Firefox , IE, etc.)
Thanks in advance!

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?

Can JavaFX call and embedd OCX Components

is JavaFX capable of loading and embedding OCX Controls? I would like to use the Internet explorer in my Application, because the WebKit browser lacks support for ActiveX. And since I have to rely on third party ActiveX Controls (I know they are evil), I am bound to the IE.
This question is not purely related to "Can I use OCX in Java" because I would like to have some kind of component for JavaFX I would like to use.
Or do I have to rely on libraries posted here:
Use a .OCX Control in Java
Thanks in advance,
Sven
You have to rely on the libraries posted in the link you supplied in your question.
Or you need to write your own JNI interface.
If you do access OCX components, you may need to place them in their own window rather than sharing a window created by a JavaFX stage as you may run into issues with the JavaFX renderer conflicting writes on the window portions in which the OCX components are displayed - you would have to try it and see what happens to confirm.
The easier way to do this may be to request that users of your application set their default browser to IE, and then call the JavaFX hostservices.showDocument(uri) api to launch an IE page which embeds the OCX components you need.
Another alternative is to:
Embed your JavaFX application as an applet in a web page.
Also embed your activex controls in the web page.
On display of the web page, check the browser and, if it isn't IE, tell they user that the must be using Internet Explorer.
Have the user accept any miscellaneous security warnings the Browser displays.
Have the user (or perhaps JavaScript) resize the browser window to fullscreen (see IE9 Full Screen Mode or Full Screen Browsers with JavaScript).
Communicate between your active X controls and java app using javascript invoked via calls from the javafx/javascript bridge and control your active X controls via VBScript embedded in the page.
It would probably work, but it is such an ugly Frankenstein solution . . .
If you can convert your media to a format which JavaFX supports and just play it back direct through JavaFX, that would be much preferable, or it may also turn out that due to a deep ActiveX integration requirement that JavaFX is not the best solution to your problem and you could be better off with something like Silverlight.

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.

Is there a way to load an applet in chrome extension?

I have written a class for my application and want to use it in making chrome extension.I tried loading applet in popup.but it seems that chrome has blocked applets. The functionality i want to embed is when user visits a page he sees a button on omnibox..when user clicks the button i want to send some page elements to my applet which processes it and saves it as a file in the filesytem. for this i want to dynamically add the applet to dom..or atleast if i can load the applet its fine!!
This is a known limitation between Java Applets and Google Chrome, for more information please refer to the following issue: http://code.google.com/p/chromium/issues/detail?id=30258

Headless HTML rendering to image on CentOS 5.4

I have a project requirement to render HTML and capture the rendered image as a file on a headless CentOS 5.4 server. My specific requirements are:
1) Input will be a URL to the page to render (or file:// URL to a local HTML file), output will be an image file containing the rendered image of the page
2) CSS must be supported by the renderer up to CSS level-1
3) Static images in the page must be displayed properly in the rendered image, including any transparent color in .GIF or .PNG files
4) Must be able to run on a headless CentOS 5.4 server.
5) Solution must not depend on any product or component that is not free for commercial use
I do not need to do anything with the page other than get the screen capture and save it to an image. The hard part seems to be doing this in a headless environment. Some of the solutions that I've seen discussed need a display in order to work.
Any suggestions?
Thanks in advance,
Jim
SOLUTION:
I ended up using the Standard Widget Toolkit library (www.eclipse.org/swt) for its embedded browser capabilities. This allowed me to programmatically open a window with a browser control in it, render the page, then capture the content of the window to an image file (usually a PNG). The only downside to this approach that cannot be avoided is a "flicker" when the window must be made visible for a moment in order to do the screen capture. I can live with it. The rest was just code to initialize the SWT objects that obtain system resources, a listener to check for a successful completion of the page load, and some code to clean up a hung connection (when the page load never completes for whatever reason).
I got a teammate to play around with xvfb (X virtual framebuffer) on CentOS Linux. The initial tests appear to work, so it looks like the advice from the poster below (who said to try xvfb) may be a viable solution for the headless server part of my issue.
You can start a virtual X-windows environment using xvfb . You can now start a regular browser to render the page and use a screencapture utility to capture the content of the window. It is not pretty, but straghtforward to do.
WebKit is open-source and embeddable, maybe you can use this in a small native app to render on a canvas and save it to disk?

Categories

Resources