Interaction between a Java app and Internet Explorer

S

sponxe

Hi,

I hope my question is not stupid.

I have developed a desktop application and I would like to make it
interact with Internet Explorer (paste a selection within Explorer into
my app). I've tried to use the Clipboard and it works until JVM says
me that the system clipboard is not available. Then it does not work
anymore so I'd like to know if there is some alternative. Have you
ever solved a problem like this?

Going OT is it to possible to use JavaScript maybe with an event
triggered via Internet Explorer Context Menu?

Thanks in advance

Sponxe
 
O

Oliver Wong

I have developed a desktop application and I would like to make it
interact with Internet Explorer (paste a selection within Explorer into
my app). I've tried to use the Clipboard and it works until JVM says
me that the system clipboard is not available. Then it does not work
anymore so I'd like to know if there is some alternative. Have you
ever solved a problem like this?

When JVM tells you that the system clipboard is not available, is this
an exception being thrown or what? And if so, what exception is being
thrown?

Maybe you should post an SSCCE (http://www.physci.org/codes/sscce.jsp)
Going OT is it to possible to use JavaScript maybe with an event
triggered via Internet Explorer Context Menu?

Might have better luck asking a group dedicated to JavaScript.

- Oliver
 
R

Roedy Green

I have developed a desktop application and I would like to make it
interact with Internet Explorer (paste a selection within Explorer into
my app). I've tried to use the Clipboard and it works until JVM says
me that the system clipboard is not available. Then it does not work
anymore so I'd like to know if there is some alternative. Have you
ever solved a problem like this?

Unsigned Applets are not allowed to use the clipboard functions. You
can manually paste info into their fields, but the program itself can
put things in the clipboard or look at them.

See http://mindprod.com/jgloss/signedapplets.html
 
A

Andrew Thompson

I have developed a desktop application and I would like to make it
interact with Internet Explorer

Why? What information has Internet Explorer got that
is so all-fired important?

If it is a web page,
1) do you control the web page?
2) why not use a JEditorPane? Using a JEditorPane, the
data becomes easily accessible, and your aplication will
be x-plat (and x-browser vendor).
 
S

sponxe

Oliver said:
When JVM tells you that the system clipboard is not available, is this
an exception being thrown or what? And if so, what exception is being
thrown?

Maybe you should post an SSCCE (http://www.physci.org/codes/sscce.jsp)

Thanks for replying. I modified heavily the code so I am unable to post
the exact code that gave me that error. However the changes I
introduced solved that problem but it is the whole clipboard approach
that is not the best way to solve this problem.

What I wanted to do is intercept text selection to paste it into my
desktop application and I thought immediately to use the clipboard.
Java however can only detect a DataFlavor change (for example from one
text type to another) and not a change of the contents of the specific
DataFlavor (for example from "Test" to "Doesn't work"). This is useless
for me because if I select always the same "type" of text a change will
not be detected.

So I tried to implement the interface ClipboardOwner. I (stupidly)
thought that I could listen for selection, paste the selection in my
app and change the Clipboard ownership putting something into it. This
introduced the flaw I was talking about (later corrected). Problem is
it requires me to change every time the clipboard ownership and if I
forget the app open it will make copy and paste unusable for all the
apps :)
Might have better luck asking a group dedicated to JavaScript.

Thanks for the suggestion but I am going to give up (I cannot dedicate
to it a lot of time). I will revert to using normal copy and paste
keys.

Thanks again!

Sponxe
 
S

sponxe

Thanks for replying.

The application is not an applet but a normal desktop application.
Maybe what I wanted to do was possible via an applet but I didn't try
that.

Sponxe
 
S

sponxe

Thanks for replying.

I did not explain well what I wanted to do. Explorer is just an example
of application I wanted to work with and I am not limited to it (every
app with copy functionality would have been a good example).

Sponxe
 
Joined
Feb 9, 2008
Messages
1
Reaction score
0
Detecting clipboard changes in Java

Sorry for necroing such an old thread, but if it can be googled by me it can be googled by someone else, I suppose.

Anyhow one way to automatically extract text from the clipboard when it changes is to use a SwingWorker that stores the current clipboard contents on initialization, and then compares the clipboard contents to the stored data however often you like. If a change is detected do what you will with the new text and update the stored data.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top