|
Barcode, labelling and utility software |
Quick_links...Search siteTrial productsOnline tutorials Products
|
Barcodes in JavadBarcode Java Classes are platform-independent Java classes that allow barcode images to be created within a developer's own Java desktop application, applet or servlet. Each product includes the class file, a JavaBean archive, and samples with source code illustrating a desktop application, an applet and a servlet. The classes are designed to work with, and the sample source code is provided for the Java 2 SDK J2SE 1.5 or later, and the J2EE SDK 1.5 (for the servlet). Products are suitable for use with BEA WebLogic Server, IBM WebSphere and Sun Java System Application Server. Setting and retrieving property valuesThe dBarcode Java classes may be operated entirely by setting or retrieving
barcode Property values programmatically. Similarly the current value of any property may be obtained using a
getProperty() method, eg. These examples require that that value used to set a property or the variable
used to receive a property must be of the correct type (as listed in the
Properties reference). Using the former method the CodeType property may be set using In these examples the property names are shown in upper case, but the Property name parameter in the setParam() method is actually case-insensitive. Displaying a barcode on a formThe dBarcodeXX classes extend the Canvas, and so can be placed on other
visible elements, such as a frame. For example, the following simple program
creates a frame containing a label and a barcode, and displays the barcode using
the data “123456”. Printing a barcode imageBarcode images may be drawn on any graphics device, one of the most important
of which is the printer. The drawBarcode() method causes the barcode to be draw
on the graphics surface (g2 in the example below), positioned at the left and
top coordinates (in points) specified by the 2nd and 3rd parameters. For
printing the remaining parameters may be 0. In fact the 4th parameter specifies
the required resolution (in dpi) of the image – but for a printer this
information is generally provided thought the graphic surface properties and
need not be specified in the method call. Saving a graphic fileBarcode images may be saved to file using the saveGraphicToFile() method,
with the first parameter as the target filename (illustrated below for a Windows
file system). The graphic image types supported depend on the platform on which
the Java VM is running, but generally include EPS, GIF, JPEG and PNG formats. Applet developmentThe sample applet included with the distribution is very “bare bones”, and
the source code is provided simply as a starting point for developers who wish
to make a more advanced applet. Examination of the source code of dbcappXX.java
in the build directory will illustrate how easy this is. The init() function is
the ideal place to set default barcode parameters. Servlet developmentServlets run on a server and return html and/or graphic code to a web browser
in response to a request from the browser. <IMG src=http://localhost/servlet/dbcserv128?CODETYPE=0&DATA=12345678> In this case the servlet returns a image – a Portable Network Graphic (PNG) image using the code in the sample servlet.
|
|
Sites operated by DL Technology Ltd
dLSoft is a registered trade mark of DL Technology Ltd, a company registered in England number 3615271
|