資源簡介
有些人太黑了,資源來自網絡,就要服務大眾。
我寫了一個簡單的例子,水平有限忘見諒。
要生成不同類型的條碼只需按注釋的位置修改就可以了。
所有的類型都在net.sourceforge.jbarcodebean.model包下,很明了。
生成的圖片路徑自己設置就可以了。

代碼片段和文件信息
package?test;
import?java.awt.image.BufferedImage;
import?java.io.FileNotFoundException;
import?java.io.FileOutputStream;
import?java.io.IOException;
import?java.io.OutputStream;
import?javax.imageio.ImageIO;
import?net.sourceforge.jbarcodebean.JBarcodeBean;
import?net.sourceforge.jbarcodebean.model.Ean13;
class?JBB?{
public?static?void?main(String[]?args)?{
JBarcodeBean?jBarcodeBean?=?new?JBarcodeBean();
//?條形碼類型
jBarcodeBean.setCodeType(new?Ean13());
// jBarcodeBean.setCodeType(new?Code39());
//?jBarcodeBean.setBarcodeHeight(200);
//?在條形碼下面顯示文字
jBarcodeBean.setLabelPosition(JBarcodeBean.LABEL_BOTTOM);
OutputStream?out;
try?{
out?=?new?FileOutputStream(“a.gif“);
jBarcodeBean.setCode(“6922507005033“);
BufferedImage?image?=?new?BufferedImage(200?200
BufferedImage.TYPE_INT_RGB);
image?=?jBarcodeBean.draw(image);
ImageIO.write(image?“JPEG“?out);
}?catch?(FileNotFoundException?e)?{
e.printStackTrace();
}
//?設置條形碼的值
catch?(IOException?e)?{
e.printStackTrace();
}
}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????1096??2011-08-24?12:18??JBarcodeBean例子\JBB.java
?????文件??????61650??2011-08-24?11:53??JBarcodeBean例子\jbarcodebean-1.2.0.jar
?????目錄??????????0??2011-08-24?12:18??JBarcodeBean例子
-----------?---------??----------?-----??----
????????????????62746????????????????????3
評論
共有 條評論