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
In questa pagina del sito puoi guardare il video online Generate bar code and QR code in Java easy tutorial | Java tutorials | Java bar code full tutorial della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Muhammad Shahzaib 11 aprile 2024, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 72 volte e gli è piaciuto 5 spettatori. Buona visione!