ASSALAM o alaikum
zxing download link :
jar-download.com/artifacts/com.google.zxing/javase
/// copy above link and paste in your browser
Code :
/*
真主
穆罕默德 真主啊,为我们的大师穆罕默德和他的家人祈祷与和平 77 85 72 65 77 77 65 68 32
83 104 97 104 122 97 105 98
*/
import java.util.UUID;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import java.awt.image.BufferedImage;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.MultiFormatWriter;
import com.google.zxing.WriterException;
import com.google.zxing.client.j2se.MatrixToImageWriter;
import com.google.zxing.common.BitMatrix;
public class BarCodegenerator {
///////////// method that generates unique id, converts it to String and returns that
public String getUniqueId(){
return UUID.randomUUID().toString();
}
////////// main method /////////////////////
public static void main(String[] args){
BarCodegenerator barCodegenerator= new BarCodegenerator();
barCodegenerator.ShowBarCode();
// String id= barCodegenerator.getUniqueId();
// System.out.println(id);
}
////////// method that displays UI and show all results ///////////////////
void ShowBarCode(){
JFrame frame= new JFrame("Bar code generator");
frame.setSize(400, 400);
String identifier= getUniqueId();
BufferedImage barcode= getBodecode(identifier);
JLabel barCodeLabel= new JLabel("code :"+ identifier);
barCodeLabel.setBounds(20, 50, 500, 30);
JLabel imageLabel = new JLabel();
imageLabel.setIcon(new ImageIcon(barcode));
frame.add(barCodeLabel);
frame.add(imageLabel);
frame.setVisible(true);
frame.setDefaultCloseOperation(1);
}
///////////// method that generates bar code form an unique identifier and returns it as Buffered Image ///////////////
public BufferedImage getBodecode(String identifier) {
String format= "CODE_128";
BarcodeFormat barcodeFormat= BarcodeFormat.valueOf(format);
MultiFormatWriter multiFormatWriter= new MultiFormatWriter();
try {
BitMatrix bitMatrix= multiFormatWriter.encode(identifier,barcodeFormat,200,100);
BufferedImage bufferedImage= MatrixToImageWriter.toBufferedImage(bitMatrix);
return bufferedImage;
} catch (WriterException e) {
e.printStackTrace();
return null;
}
}
}
//// zxing github link //////////////////////////////
github.com/zxing/zxing
//////// zxing maven link //////////////////////
repo1.maven.org/maven2/com/google/zxing/javase/3.2.0/
Credits :
1. www.labelsandlabeling.com/sites/labels/lnl/files/Books/figure_1.1_-_barcodes_-_a_pattern_of_black_and_white_lines.png
2. www.google.com/url?sa=i&url=https%3A%2F%2Fwww.labelsandlabeling.com%2Flabel-academy%2Farticle%2Fintroduction-barcodes-and-barcoding-technology&psig=AOvVaw2YRKEoLmLOwao_VEGE0hz3&ust=1711972232908000&source=images&cd=vfe&opi=89978449&ved=0CBQQjhxqFwoTCLCIiKKwuoUDFQAAAAAdAAAAABAE
For complaint/suggestions :
mshahzaib6699@gmail.com
On this page of the site you can watch the video online Generate bar code and QR code in Java easy tutorial | Java tutorials | Java bar code full tutorial with a duration of hours minute second in good quality, which was uploaded by the user Muhammad Shahzaib 11 April 2024, share the link with friends and acquaintances, this video has already been watched 72 times on youtube and it was liked by 5 viewers. Enjoy your viewing!