2 Replies Latest reply: Mar 27, 2014 7:16 AM by ptoye RSS

    How to print Swing components in Windows?

    ptoye

      I'm using Java 7 in a Windows 7 system. I want to print the current JFrame to the current printer, so call print(getGraphics()); But nothing happens. I assume that this is because "print" in UNIX-based systems means "send to output stream" rather than "print to printer".

       

      So, how do I get the frame with all its contents printed please? Searching the Swing tutorials for "print" doesn't bring up anything useful.

       

      Thanks in advance.

        • 1. Re: How to print Swing cmponents in Windows?
          TPD-Opitz

          ptoye wrote:

           

          I'm using Java 7 in a Windows 7 system. I want to print the current JFrame to the current printer, so call print(getGraphics()); But nothing happens.

          on which object/class did you call "print()"?

          I assume that this is because "print" in UNIX-based systems means "send to output stream" rather than "print to printer".

          No.

          This meight be becaue "printing" usually does not mean "send a screen capture to the printer".

           

          So, how do I get the frame with all its contents printed please? Searching the Swing tutorials for "print" doesn't bring up anything useful.

           

          Thanks in advance.

          look here

           

          bye TPD

          • 2. Re: How to print Swing cmponents in Windows?
            ptoye

            Thanks - I've now found that I need to look at the Printable interface. Pity the tutorials don't seem to mention it.

             

            [Later] I've now found the tutorial - Lesson: Printing (The Java™ Tutorials > 2D Graphics)

             

            1) I was calling print() on the Jframe.

             

            2) That was my point!

             

            3) Your pointer is very helpful. [Later]... but it doesn't show the tutorial above! But it does show links to the stackoverflow site which I'm finding useful.

             

            Peter