为什么iText的PdfWriter在导出为可运行的jar时会将JTextField打印为黑色?

我有一个奇怪的难题。 我目前正在尝试创建一个我正在研究的Eclipse项目的Runnable Jar,其中包含许多JTextField和JFormattedTextField,它们都很好地安排在JPanel中。 我正在使用这些JPanel并打印出来使用iText的漂亮的PdfWriter。

问题是:在Eclipse中,打印出来就好了。 当我将项目导出到可运行的jar中时,我得到以下内容:

我的问题

所有这些黑色矩形都是我的JTextField和JFormattedTextField所在的位置。

有谁知道可能导致这种情况的原因是什么? 这就是我打印出来的方式,记住,它在Eclipse中工作,但在导出为runnable jar时却没有:

private void print() throws DocumentException, IOException { Document document = new Document(PageSize.LETTER, 0, 0, 0, 0); File file = new File(System.getProperty("user.home") + File.separator + "Desktop" + File.separator + "temp.pdf"); if (!file.exists()) { file.createNewFile(); } PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(file)); document.open(); PdfContentByte contentByte = writer.getDirectContent(); int x = (int) document.getPageSize().getWidth() / 2 - 250; int y = (int) document.getPageSize().getHeight() - 375; for (int i = 0; i < jobs.size(); i++) { jobs.get(i).setFocusable(false); contentByte.moveTo(0, y + 235); contentByte.lineTo(document.getPageSize().getWidth(), y + 235); contentByte.closePathStroke(); y += 5; PdfTemplate template = contentByte.createTemplate(600, 250); @SuppressWarnings("deprecation") Graphics2D g2 = template.createGraphics(600, 250); jobs.get(i).print(g2); g2.dispose(); contentByte.addTemplate(template, x, y); y -= 105; jobs.get(i).setFocusable(true); } contentByte.moveTo(0, y + 235); contentByte.lineTo(document.getPageSize().getWidth(), y + 235); contentByte.closePathStroke(); y = 25; PdfTemplate template = contentByte.createTemplate(600, 25); @SuppressWarnings("deprecation") Graphics2D g2 = template.createGraphics(600, 25); total.setFocusable(false); totalPanel.setOpaque(false); totalPanel.print(g2); g2.dispose(); contentByte.addTemplate(template, x - 65, y); total.setFocusable(true); totalPanel.setOpaque(true); document.close(); } 

感谢您所有的帮助!