void update() {
   Document newDoc = getDocument();
   Document oldDoc = docRef.get();
   if (newDoc != oldDoc) {
     if (oldDoc != null) {
       ScaleModel model = oldDoc.getScaleModel();
       model.removeScaleListener(this);
     }
     if (newDoc != null) {
       ScaleModel model = newDoc.getScaleModel();
       model.addScaleListener(this);
       setEnabled(model.canScaleUp());
     } else {
       setEnabled(false);
     }
     docRef = new WeakReference<Document>(newDoc);
   }
 }
 public void scaleChanged(Scale scale) {
   Document doc = getDocument();
   ScaleModel model = doc.getScaleModel();
   setEnabled(model.canScaleUp());
 }
 public void actionPerformed(ActionEvent event) {
   Document doc = getDocument();
   ScaleModel model = doc.getScaleModel();
   model.scaleUp();
 }