有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java在条形码上方添加文本,并使用烧烤更改字体大小

我正在使用Barbike在java中生成条形码。它成功地生成了条形码,但存在一个小问题。我想在条形码上方添加一些小文本。我还想更改条形码下方文本/数字的字体大小/样式,并删除下划线。你是怎么做到的

这是我的密码:

private void btnGenerateBarcodeActionPerformed(java.awt.event.ActionEvent evt) {                                                   
    // TODO add your handling code here:
    String text=txtText.getText();
    File file = new File("path/to/destination/file");
    try {

        Barcode barcode = BarcodeFactory.createCode128(text);
        barcode.setBarHeight(50);
        barcode.setBarWidth(1);
        BarcodeImageHandler.saveJPEG(barcode,file);

        JOptionPane.showMessageDialog(this, "Barcode generated successfully!",
            "Success",JOptionPane.INFORMATION_MESSAGE);

    } catch (Exception e) {
        JOptionPane.showMessageDialog(this, "Error generating barcode\n"+e.toString(),
                "Error",JOptionPane.ERROR_MESSAGE);
    }
}      

barcode


共 (0) 个答案