The following code illustrates how to create a linear (1D) barcode in a java.awt.Image object:
Linear linear=new Linear();
linear.setSize(400,200);
// create image
java.awt.image.BufferedImage image = new java.awt.image.BufferedImage(
linear.getSize().width,linear.getSize().height,java.awt.image.BufferedImage.TYPE_BYTE_INDEXED
);
// get graphic context of image
java.awt.Graphics imgGraphics = image.createGraphics();
// paint barcode in graphics context of image
linear.paint(imgGraphics );