import java.awt.print.PageFormat;
import java.awt.print.PrinterJob;
import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
import java.io.File;
import java.io.FileWriter;
import java.io.PrintWriter;
if (Desktop.getDesktopPane() != null)
{
this.setDropTarget(new java.awt.dnd.DropTarget(this, this));
- if (!Platform.isJS())
+ PropertyChangeListener serviceListener = (Platform.isJS() ? null
+ : addServiceListeners());
+ addInternalFrameListener(new javax.swing.event.InternalFrameAdapter()
{
- addServiceListeners();
- }
+ @Override
+ public void internalFrameClosed(
+ javax.swing.event.InternalFrameEvent evt)
+ {
+ // System.out.println("deregistering discoverer listener");
+ if (serviceListener != null)
+ {
+ Desktop.getInstance().removeJalviewPropertyChangeListener(
+ "services", serviceListener);
+ }
+ closeMenuItem_actionPerformed(true);
+ }
+ });
+
setGUINucleotide();
}
}
/* Set up intrinsic listeners for dynamically generated GUI bits. */
- private void addServiceListeners()
+ private PropertyChangeListener addServiceListeners()
{
- final java.beans.PropertyChangeListener thisListener;
- Desktop.getInstance().addJalviewPropertyChangeListener("services",
- thisListener = new java.beans.PropertyChangeListener()
+ PropertyChangeListener serviceListener = new PropertyChangeListener()
{
@Override
public void propertyChange(PropertyChangeEvent evt)
});
}
}
- });
- addInternalFrameListener(new javax.swing.event.InternalFrameAdapter()
- {
- @Override
- public void internalFrameClosed(
- javax.swing.event.InternalFrameEvent evt)
- {
- // System.out.println("deregistering discoverer listener");
- Desktop.getInstance().removeJalviewPropertyChangeListener("services",
- thisListener);
- closeMenuItem_actionPerformed(true);
- }
- });
+ };
+
+ Desktop.getInstance().addJalviewPropertyChangeListener("services",
+ serviceListener);
// Finally, build the menu once to get current service state
new Thread(new Runnable()
{
BuildWebServiceMenu();
}
}).start();
+ return serviceListener;
}
/**