This *can* be done in Java - but it has nothing to do with Swing directly.
You're going to have to read from the bar-code scanner somehow - Serial Port, USB, Parallel Port - whatever. The link gives some libraries that you will need to interface with however your specific device connects. Once you figure out how to connect to your device, you're going to need to figure out how your device communicates barcodes - again specific to the device.
Once you have a way to talk to the device connection, and a way to figure out how the device is sending you barcode information - *THEN* you're going to use Swing to write the GUI.
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Typically what I've seen is that the scanner devices utilizes a native driver on the OS and all the scanner really does is spit the bar code info out to whatever focused text component there is. This could be Notepad, Word, Excel, or your swing app. So you might check that as well.
Some libraries you may find useful when showing/generating barcodes are iText (creates PDF files containing barcodes) and barcode4j and jbarcodebean (both on SourceForge) for creating images of barcodes.
Ping & DNS - updated with new look and Ping home screen widget
Yup I worked on a Java Point of Sale application that used a bar code reader. The bar code reader basically went between the keyboard and the computer and sent the bar code in as text. There are of course other bar code readers including serial port models. We actually had magnetic strip readers too and they also came in via the keyboard.
The bar code scanner came with software to produce the bar codes to put on products so we didn't need to produce or consume bar code images in Java. Just decide on the bar code number, put it in the DB for the product, print bar codes using software, bar code comes in as text from the keyboard, compare against DB.
Originally posted by Gregg Bolinger: Typically what I've seen is that the scanner devices utilizes a native driver on the OS and all the scanner really does is spit the bar code info out to whatever focused text component there is. This could be Notepad, Word, Excel, or your swing app. So you might check that as well.
I have the same experience with barcode scanners. We even have developed a web application. Each scan is just put to whatever focused text component there is, just as it would come from the keyboard. We have never written anything that "gets" the data, the scanner always "pushes" it to the application.