Java小程序和打印
在我的网页中,我正在调用具有一些凭据信息的小程序,并尝试打印小程序内容。但我需要隐藏小程序信息。假设我正在尝试看不见的editorpane或Jframe,那么这篇文章将是一片空白Java小程序和打印,java,swing,applet,Java,Swing,Applet,在我的网页中,我正在调用具有一些凭据信息的小程序,并尝试打印小程序内容。但我需要隐藏小程序信息。假设我正在尝试看不见的editorpane或Jframe,那么这篇文章将是一片空白 //Print function Graphics2D g2d = (Graphics2D) g; g2d.translate(pageFormat.getImageableX(), pageFormat .getImageableY());
//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()
新实例。不要使用paint
,使用print
或printAll
…您不需要禁用双缓冲,因为这些方法也是这样做的,您可能需要确保正在打印的组件实际大小正确我尝试使用printAll函数..但我无法实现..还检查了组件大小..我刚刚做了一个独立的小示例,它对我来说很好。也许你应该考虑提供一个