I am making an application to generate barcodes, but it does not give me the barcode: the application returns the text that I have provided. My code is:
Code39 code39=new Code39();
String outputStr=code39.encode("12345678", 1);
String humanTextStr=code39.getHumanText();
jLabel1.setText(outputStr);
jLabel1.setFont(new java.awt.Font("CCode39_S3",java.awt.Font.PLAIN,24));
Please can anyone tell me why this happens?
To generate a QR code in Java, we need to use a third-party library named ZXing (Zebra Crossing). It is a popular API that allows us to process with QR code. With the help of the library, we can easily generate and read the QR code.
The barcode generator allows you to create a barcode graphic by providing barcode symbology and data. Click on the Generate Barcode to create a graphic containing your barcode. Right click to copy or save the barcode, then paste or insert the barcode into your document.
Your application is returning a text because you have told it to get the text not the bar-code.
Try the following code:
a=jTextField24.getText();
Code39 barcode=new Code39();
barcode.setData(a);
ImageIcon icon = new ImageIcon(barcode.drawBarcode());
jLabel34.setIcon(icon);
Try using open source libraries for generating barcodes in java. For e.g., iText or http://barbecue.sourceforge.net/
Please refer to this link as well BarCode Image Generator in Java
Hope it helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With