Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

KeyListner for non-awt-swing class

 
Liming Xu
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all, I have a bean class and I want to register it so that it's able to do something when a Keyboard event is fired. It's not a AWT/SWing componet...because I want it to be able to get keyboard stroke without providing any visual components. How do I do that? Thanks a lot.
Liming
 
Liming Xu
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
BTW, mabye it'll be more clear this way. We are writing an application for a Scanner utitly(web based). Many scanner on the market connects to PS/2 keyboard port, so when the clients scan using this kind of Scanner, we want to be able to read the keyboard characters behind the background by invoke a bean class. The web developer will call my bean from a page, and my bean is suppose to sit in the background and read keyboard events. Obviously, I can't ask ppl to open a command prompt whenver the user reach that webpage, (btw, user is on serverside as well), so reading input from command prompt is not going to help.
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All of the events in Java are in the AWT and are intended for GUI interactions. If you want to watch for stuff outside of a Java GUI you are going to need to use some operating system level operations, which of course will prevent it from being platform independant.
The best that I can suggest is to see how the Java events are handled in the AWT and "borrow" some of that code to use as a basis for what you need.
and Lim,
Please change your name to be compliant with JavaRanch's naming policy.
Your ID should be 2 separate names with more than 1 letter each. We really want this to be a professional forum and would prefer that you use your REAL name.
Thanks,
Cindy
 
Liming Xu
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Cindy.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic