Getting Device to Print

Via X windows the following command changes the shape of the pointer (cursor). Point it at any window and click. xprint.ps should then contain a window dump. (This seems to only give black and white prints.)

xwd | xpr -device ps -protrait > xprint.ps

Via Solaris the program snapshot will do window dumps, allow you to preview the image it obtained and send it to the printer. However the next set of programs have black backgrounds. Use xv color editor to change black to white and then print. Via Sgi the program snapshot is different from the solaris version but has similar functionality. Other operating systems have other screen dump programs.

Via Print Job the following additions to Device will pull up a print dialog which is suppose to do the right thing. This is a kludge which uses a separate thread to start the print job after 3 seconds.

  1. Add ", Runnable" after "implements WireMesh".
  2. Add the following to the bottom of main.
    		Thread t = new Thread(d);
    		t.start();
    
  3. Add the member function below to Device. This is "Runnable"
        public void run () {
            Thread thread = Thread.currentThread();
            try {
                thread.sleep(3000); // wait 3 seconds
            } catch ( InterruptedException e ) {
                System.out.println ( "PrintJob" );
            }
            Component c = this.getParent();
            while ( c != null && ! (c instanceof Frame) )
                c = c.getParent();
    
            PrintJob pj = getToolkit().getPrintJob( (Frame) c, "test", null );
            Graphics pg = pj.getGraphics();
            //printAll(pg);
            if ( pg != null ) {
                paint(pg);
                pg.dispose();
            }
            pj.end();
        }