从我的网页上,我调用具有一些凭据信息的小程序,并尝试打印小程序内容。但我需要隐藏小程序信息。如果假设我正在尝试隐藏编辑器 Pane 或 Jframe,则纸张将显示为空白。
//Print function
Graphics2D g2d = (Graphics2D) g;
g2d.translate(pageFormat.getImageableX(), pageFormat
.getImageableY());
disableDoubleBuffering(componentToBePrinted);
componentToBePrinted.paint(g2d);
enableDoubleBuffering(componentToBePrinted);
return (PAGE_EXISTS);
// applet
jbInit();
this.accessParamEditorPane.setEditable(false);
Font f = new Font("Arial", 1, 9);
this.accessParamEditorPane.setFont(f);
this.accessParamEditorPane.setText(Body);
//this.setVisible(false);
//accessParamEditorPane.setVisible(false);
new PrintModule(this);
dispose();
setFocusableWindowState(false);
最佳答案
您可以尝试创建另一个 JEditorPane
实例(可见)。复制原始文件的大小,设置相同的 EditorKit
并设置从原始文件获取的文档。
然后printAll()
新实例。
关于Java Applet 和打印,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18629817/