Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Keylistener in JPanel (moved from J2EE forum)

Status
Not open for further replies.

mes123

Programmer
Jul 29, 2005
62
0
0
GB
I have a jPanel (that contains amoungst other things a jScrollPane and JTable). I'm trying to get input from a barcode reader to display in the table.

Since this GUI will run on a touch screen I don't want to have to forch the use to set the focus on the table or any sort of textfield. I just want them to be able to scan an item with the barcode scanner and trap the data (the barcode scanner can be thought of as just a keyboard).

Is there a way of attaching a keyListener to the jPanel so that it can accept keyboad input? I can make the table and scrollpane non focusable then (I don;t really want the use being able to input directly in then anyhow)

Thanks in advance.

 
I'm not overly great at Swing, but I believe you need to have a generic key listener, use the JPanel.addKeyListener() method (inherited from Component), and update components in your JPanel accordingly.

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top