把applet嵌入到HTML中,在HTML中加入显示applet的代码<applet>...代码</applet>,再写<a href="javascript:print()"><font color="#0000FF">打印</font></a>
然后桌面上的Internet Explorer的属性中点击高级,在打印选项中勾中打印背景颜色和图象。想要去掉页码和地址,在IE工具栏的文件下的页面设置里修改。

解决方案 »

  1.   

    可以把画的东西转化为图片,再打印。
            BufferedImage image = new java.awt.image.BufferedImage(tree.getPreferredSize().width, tree.getPreferredSize().height,
                java.awt.image.BufferedImage.TYPE_INT_ARGB);
            Graphics g = image.createGraphics();
            g.setColor(Color.black);
    //            g.fillRect(0, 0, image.getWidth(), image.getHeight());
            tree.paint(g);
            tree.paintComponents(g);
            try{
                javax.imageio.ImageIO.write(image, "PNG", imgFile);
            }
            catch(IOException e){
                JOptionPane.showMessageDialog(this, "IO exception, export image failed.");
                e.printStackTrace();
            }