Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/347.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java小程序和打印_Java_Swing_Applet - Fatal编程技术网

Java小程序和打印

Java小程序和打印,java,swing,applet,Java,Swing,Applet,在我的网页中,我正在调用具有一些凭据信息的小程序,并尝试打印小程序内容。但我需要隐藏小程序信息。假设我正在尝试看不见的editorpane或Jframe,那么这篇文章将是一片空白 //Print function Graphics2D g2d = (Graphics2D) g; g2d.translate(pageFormat.getImageableX(), pageFormat .getImageableY());

在我的网页中,我正在调用具有一些凭据信息的小程序,并尝试打印小程序内容。但我需要隐藏小程序信息。假设我正在尝试看不见的editorpane或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()
新实例。

不要使用
paint
,使用
print
printAll
…您不需要禁用双缓冲,因为这些方法也是这样做的,您可能需要确保正在打印的组件实际大小正确我尝试使用printAll函数..但我无法实现..还检查了组件大小..我刚刚做了一个独立的小示例,它对我来说很好。也许你应该考虑提供一个