Barbecue is a free and open source Java library for Barcode generation. This requires the library barbecue-1.5-beta1.jar to be in classpath. The following example shows rendering CODE 128B Barcode as Swing component.
package com.bethecoder.tutorials.barbecue; import javax.swing.JFrame; import net.sourceforge.barbecue.Barcode; import net.sourceforge.barbecue.BarcodeFactory; public class BarCodeAsSwingComponentTest { public static void main (String [] args) throws Exception { //Get 128B Barcode instance from the Factory Barcode barcode = BarcodeFactory.createCode128B("be the coder"); JFrame frame = new JFrame("My Application"); frame.getContentPane().add(barcode); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setLocation(240, 90); frame.setVisible(true); } }