import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
-import java.awt.event.MouseListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
-import java.beans.PropertyVetoException;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileOutputStream;
import javax.swing.SwingUtilities;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkEvent.EventType;
+import javax.swing.event.InternalFrameAdapter;
+import javax.swing.event.InternalFrameEvent;
import javax.swing.event.MenuEvent;
import javax.swing.event.MenuListener;
* ((openFrameCount - 1) % 10) + yOffset);
}
+ /*
+ * add an entry for the new frame in the Window menu
+ * (and remove it when the frame is closed)
+ */
final JMenuItem menuItem = new JMenuItem(title);
- frame.addInternalFrameListener(new javax.swing.event.InternalFrameAdapter()
+ frame.addInternalFrameListener(new InternalFrameAdapter()
{
@Override
- public void internalFrameActivated(
- javax.swing.event.InternalFrameEvent evt)
+ public void internalFrameActivated(InternalFrameEvent evt)
{
JInternalFrame itf = desktop.getSelectedFrame();
if (itf != null)
{
itf.requestFocus();
}
-
}
@Override
- public void internalFrameClosed(
- javax.swing.event.InternalFrameEvent evt)
+ public void internalFrameClosed(InternalFrameEvent evt)
{
PaintRefresher.RemoveComponent(frame);
{
openFrameCount--;
}
+
+ /*
+ * ensure no reference to alignFrame retained by menu item listener
+ */
+ if (menuItem.getActionListeners().length > 0)
+ {
+ menuItem.removeActionListener(menuItem.getActionListeners()[0]);
+ }
windowMenu.remove(menuItem);
JInternalFrame itf = desktop.getSelectedFrame();
if (itf != null)
{
itf.requestFocus();
+ if (itf instanceof AlignFrame)
+ {
+ Jalview.setCurrentAlignFrame((AlignFrame) itf);
+ }
}
System.gc();
};
}
}
});
- menuItem.addMouseListener(new MouseListener()
- {
-
- @Override
- public void mouseReleased(MouseEvent e)
- {
- }
-
- @Override
- public void mousePressed(MouseEvent e)
- {
- }
-
- @Override
- public void mouseExited(MouseEvent e)
- {
- try
- {
- frame.setSelected(false);
- } catch (PropertyVetoException e1)
- {
- }
- }
-
- @Override
- public void mouseEntered(MouseEvent e)
- {
- try
- {
- frame.setSelected(true);
- } catch (PropertyVetoException e1)
- {
- }
- }
-
- @Override
- public void mouseClicked(MouseEvent e)
- {
-
- }
- });
windowMenu.add(menuItem);
@Override
public void closeAll_actionPerformed(ActionEvent e)
{
+ // TODO show a progress bar while closing?
JInternalFrame[] frames = desktop.getAllFrames();
for (int i = 0; i < frames.length; i++)
{
{
}
}
+ Jalview.setCurrentAlignFrame(null);
System.out.println("ALL CLOSED");
if (v_client != null)
{
{
ssm.resetAll();
}
+ System.gc();
}
@Override