import java.awt.event.*;
import java.awt.*;
import java.util.Properties;

/**
 * open a file dialog to read the name of an image
 * 
 * @author Owen Astrachan 
 */

public class PrintCommand implements ActionListener
{
    public PrintCommand(Frame f, Controller c)
    {
	myControl = c;
	myFrame   = f;
	myPrintProps = new Properties(); // user preferences
    }

    public void actionPerformed(ActionEvent ev)
    {
	PrintJob pj = myFrame.getToolkit().getPrintJob(myFrame,
						       "Harpoon Print",
						       myPrintProps);
	
	if (pj == null) return;     // user cancelled
	
	Graphics g = pj.getGraphics();

	// draw border and translate, see Nutshell example

	Dimension dim = myFrame.getSize();
//	g.translate(100,100);       
	g.drawRect(-1,-1, dim.width, dim.height);

	// clip frame
	
	g.setClip(0,0, dim.width, dim.height);

	myFrame.printAll(g);

	g.dispose();
	pj.end();
    }

    private Controller myControl;
    private Frame      myFrame;
    private Properties myPrintProps;
}

