FileDocCategorySizeDatePackage
JuliaSet2.javaAPI DocExample5004Sat Jan 24 10:44:36 GMT 2004je3.print

JuliaSet2

public class JuliaSet2 extends JuliaSet1
This class extends JuliaSet1 and overrides the print() method to demonstrate the Java 1.2 printing API.

Fields Summary
Constructors Summary
public JuliaSet2()

 this(.4, .4); 
public JuliaSet2(double cx, double cy)

 super(cx,cy); 
Methods Summary
public voidprint()

	// Java 1.1 used java.awt.PrintJob.
	// In Java 1.2 we use java.awt.print.PrinterJob
	PrinterJob job = PrinterJob.getPrinterJob();

	// Alter the default page settings to request landscape mode
	PageFormat page = job.defaultPage();
	page.setOrientation(PageFormat.LANDSCAPE);  // landscape by default

	// Tell the PrinterJob what Printable object we want to print.
	// PrintableComponent is defined as an inner class below
	String title = "Julia set for c={" + cx + "," + cy + "}";
	Printable printable = new PrintableComponent(this, title);
	job.setPrintable(printable, page);

	// Call the printDialog() method to give the user a chance to alter
	// the printing attributes or to cancel the printing request.
	if (job.printDialog()) {
	    // If we get here, then the user did not cancel the print job
	    // So start printing, displaying a dialog for errors.
	    try { job.print(); }
	    catch(PrinterException e) {
		JOptionPane.showMessageDialog(this, e.toString(),
					      "PrinterException",
					      JOptionPane.ERROR_MESSAGE);
	    }
	}