This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Soft Skills and have John Sonmez on-line!
See this thread for details.
The moose likes Applets and the fly likes Applet always listen for events Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "Applet always listen for events" Watch "Applet always listen for events" New topic
Author

Applet always listen for events

Antonio Foglia
Greenhorn

Joined: Jun 30, 2013
Posts: 17
Here's my scenario: i have to develop an applet connected with some devices through JavaPos. There are some examples and i've done a couple of tests. Then i've to put this applet into a web page and always listen to events. I've made a simple keyListener Applet to real test interaction between the applet and an hardware. But when i go outside the applet interface it seems to not receive input from keyboard. I think it will be the same with JavaPos code. I want my applet to always listen for events! Is there a way to always running Applet code inside a web page? Is there a way to set a javascript function, inside of my web page, as a listener?

Thanks
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18987
    
    8

You can't have your applet spy on keystrokes which are meant to be received by other applications running on the same computer.

However it seems to me that your actual requirements don't involve listening to the keyboard, but to events generated by some other hardware. Am I right? You didn't describe these devices, nor did you describe the events you want to listen to. If the events aren't keystrokes then your test which tries to work with keystrokes isn't very useful. So perhaps you could describe your requirements more clearly.
Antonio Foglia
Greenhorn

Joined: Jun 30, 2013
Posts: 17
Paul Clapham wrote:You can't have your applet spy on keystrokes which are meant to be received by other applications running on the same computer.

However it seems to me that your actual requirements don't involve listening to the keyboard, but to events generated by some other hardware. Am I right? You didn't describe these devices, nor did you describe the events you want to listen to. If the events aren't keystrokes then your test which tries to work with keystrokes isn't very useful. So perhaps you could describe your requirements more clearly.


Ok i'll be clearer.
I've to implement some JavaPos code into my applet. In this first moment i am checking the requirements i need.
Thanks to javaPos i can run an application that listen to a card reader (as in my case). Still i haven't the necessary libraries to develop the application JavaPOS, so in this moment I want to better understand the functioning of the applet in a web page.
I need that my applet always listens for events, here's my solutions even if i don't know if are correct
-applet always on focus
-run a thread from the applet
-javascript check if the applet is alive
-javascript give the focusOn to the applet
-javascript listen to the applet

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18987
    
    8

I only have two things to say. First, an applet is probably a bad choice if you want it to interact with the environment in any non-standard way. In general you would be better off to use a Java application rather than an applet. And second, until you find out what these "events" are you shouldn't make any implementation decisions at all.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Applet always listen for events