import java.awt.*; import java.awt.event.*; import java.util.*; import utilities.*; public class SignMeClient extends Frame implements SignatureEventListener { protected SignMe sigWindow; //------------------------------------------------------------------- // main() entry point //------------------------------------------------------------------- public static void main (String[] args) { new SignMeClient(); } //------------------------------------------------------------------- // SignMeClient's constructor //------------------------------------------------------------------- public SignMeClient() { super("SignMe Demo Window"); // give Frame a title sigWindow = new SignMe(); // create a SignMe component // register us as listener for "userSigned" event. try { sigWindow.addSignatureListener(this); } catch (TooManyListenersException ex) { System.out.println("Could not register: " + ex); } add(sigWindow, "Center"); // center spot of BorderLayout setSize(new Dimension(350,250)); // 1.0 resize() setVisible(true); // 1.0 show() } //------------------------------------------------------------------- // implementation of SignatureEventListener interface // To show that we can obtain the signature from the SignMe component, // pop open a second window and display the signature in it for 10 secs. // Close window again. //------------------------------------------------------------------- public void userSigned(SignatureEvent signed) { Frame receivedSigWindow; Graphics g; Image sigImage; int width, height; receivedSigWindow = new Frame("Received Signature"); sigImage = signed.getSignature(); width = sigImage.getWidth(this); height= sigImage.getHeight(this); // pop open feedback window receivedSigWindow.setSize(new Dimension(width+20, height+20)); receivedSigWindow.setVisible(true); // give AWT some time to pop open window, otherwise the image we // blit into it will be erased straight away (this is an AWT bug) MiscKit.delay(300); // draw signature in window g = receivedSigWindow.getGraphics(); int x = receivedSigWindow.getInsets().left; int y = receivedSigWindow.getInsets().top; g.drawImage(sigImage, x,y, receivedSigWindow); MiscKit.delay(10000); receivedSigWindow.setVisible(false); // hide window } } // End of Class SignMeClient