user2698555
user2698555

Reputation: 35

I have proplem in java i cant print all swing compont

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

Upvotes: 0

Views: 258

Answers (1)

MadProgrammer
MadProgrammer

Reputation: 347194

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...

Upvotes: 2

Related Questions