0

hi everyone I'm trying to print all my swing components i find this code Could anyone explain me what does the gettoolkit() do? this is the code

Toolkit tkp = jPanel9.getToolkit();
PrintJob pjp = tkp.getPrintJob(this, null, null);
Graphics g = pjp.getGraphics();
jPanel9.print(g);

I can print one swing component bay calling print() method but not all component in the jpanel

No Idea For Name
  • 11,411
  • 10
  • 42
  • 70
user2698555
  • 35
  • 1
  • 5

1 Answers1

2

You should use printAll over print

From the JavaDocs

public void print(Graphics g)

Prints this component. Applications should override this method for components that must do special processing before being printed or should be printed differently than they are painted. The default implementation of this method calls the paint method.

The origin of the graphics context, its (0, 0) coordinate point, is the top-left corner of this component. The clipping region of the graphics context is the bounding rectangle of this component.

And PrintAll...

public void printAll(Graphics g)

Prints this component and all of its subcomponents. The origin of the graphics context, its (0, 0) coordinate point, is the top-left corner of this component. The clipping region of the graphics context is the bounding rectangle of this component.

Possible examples...

Community
  • 1
  • 1
MadProgrammer
  • 343,457
  • 22
  • 230
  • 366