Search code examples
javabarcodebarcode-scanner

How to create an actionPerformed event with a barcode being scanned?


I have a barcodescanner in my java application. When the barcode is scanned we display all the associated information except the barcode itself in a table which has the focus. The GUI for now only has a table with the columns Name and Price, nothing more. It's used to display the information. When the user likes what he see he can scan another barcode which is used to send the data to the database.

Now, how do I get the data from the barcodescanner in the GUI and how do I send this data to the database by scanning a specific barcode? It's my first time using a barcodescanner to perform an action.

Thx in advance!


Solution

  • As far as I know most of barcode scanners emulate keyboard keypresses, so you can set focus to input field, scan the barcode and save the text data from the field in any place you want. You can use keypress listeners to determine if user have scanned a barcode.