From: Ben Soares Date: Mon, 18 Apr 2022 09:31:38 +0000 (+0100) Subject: JAL-3288 Replace all javax.swing.JInternalFrame with extended jalview.jbgui.ClassicJI... X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=cbdf701c27664c48d6b8cbb21c95c9994c5e97b6;p=jalview.git JAL-3288 Replace all javax.swing.JInternalFrame with extended jalview.jbgui.ClassicJInternalFrame --- diff --git a/src/jalview/fts/core/GFTSPanel.java b/src/jalview/fts/core/GFTSPanel.java index ea206e9..60f7937 100644 --- a/src/jalview/fts/core/GFTSPanel.java +++ b/src/jalview/fts/core/GFTSPanel.java @@ -62,7 +62,7 @@ import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JComboBox; import javax.swing.JFrame; -import javax.swing.JInternalFrame; +import jalview.jbgui.ClassicJInternalFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; @@ -90,7 +90,7 @@ public abstract class GFTSPanel extends JPanel implements GFTSPanelI { private static final Font VERDANA_12 = new Font("Verdana", 0, 12); - protected JInternalFrame mainFrame = new JInternalFrame( + protected ClassicJInternalFrame mainFrame = new ClassicJInternalFrame( getFTSFrameTitle()); protected JTabbedPane tabs = new JTabbedPane(); @@ -821,7 +821,7 @@ public abstract class GFTSPanel extends JPanel implements GFTSPanelI return cmb_searchTarget; } - public JInternalFrame getMainFrame() + public ClassicJInternalFrame getMainFrame() { return mainFrame; } diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index e24cbea..78b90d6 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -20,8 +20,6 @@ */ package jalview.gui; -import java.util.Locale; - import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; @@ -59,13 +57,13 @@ import java.util.Deque; import java.util.Enumeration; import java.util.Hashtable; import java.util.List; +import java.util.Locale; import java.util.Vector; import javax.swing.ButtonGroup; import javax.swing.JCheckBoxMenuItem; import javax.swing.JComponent; import javax.swing.JEditorPane; -import javax.swing.JInternalFrame; import javax.swing.JLabel; import javax.swing.JLayeredPane; import javax.swing.JMenu; @@ -141,6 +139,7 @@ import jalview.io.NewickFile; import jalview.io.ScoreMatrixFile; import jalview.io.TCoffeeScoreFile; import jalview.io.vcf.VCFLoader; +import jalview.jbgui.ClassicJInternalFrame; import jalview.jbgui.GAlignFrame; import jalview.project.Jalview2XML; import jalview.schemes.ColourSchemeI; @@ -1045,7 +1044,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, // file is reloaded. if (FileFormat.Jalview.equals(currentFileFormat)) { - JInternalFrame[] frames = Desktop.desktop.getAllFrames(); + ClassicJInternalFrame[] frames = (ClassicJInternalFrame[]) Desktop.desktop + .getAllFrames(); for (int i = 0; i < frames.length; i++) { if (frames[i] instanceof AlignFrame && frames[i] != this @@ -3414,7 +3414,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, pane = editPane; } - JInternalFrame frame = new JInternalFrame(); + ClassicJInternalFrame frame = new ClassicJInternalFrame(); frame.getContentPane().add(new JScrollPane(pane)); @@ -3437,7 +3437,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, return; } - JInternalFrame frame = new JInternalFrame(); + ClassicJInternalFrame frame = new ClassicJInternalFrame(); final OverviewPanel overview = new OverviewPanel(alignPanel); frame.setContentPane(overview); Desktop.addInternalFrame(frame, MessageManager @@ -3712,7 +3712,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, } else { - JInternalFrame frame = new JInternalFrame(); + ClassicJInternalFrame frame = new ClassicJInternalFrame(); frame.setContentPane(new PairwiseAlignPanel(viewport)); Desktop.addInternalFrame(frame, MessageManager.getString("action.pairwise_alignment"), 600, diff --git a/src/jalview/gui/AlignViewport.java b/src/jalview/gui/AlignViewport.java index 30ccdbe..3ea372f 100644 --- a/src/jalview/gui/AlignViewport.java +++ b/src/jalview/gui/AlignViewport.java @@ -62,7 +62,7 @@ import java.util.ArrayList; import java.util.Hashtable; import java.util.List; -import javax.swing.JInternalFrame; +import jalview.jbgui.ClassicJInternalFrame; /** * DOCUMENT ME! @@ -870,7 +870,7 @@ public class AlignViewport extends AlignmentViewport /* * Open in split pane. DNA sequence above, protein below. */ - JInternalFrame splitFrame = new SplitFrame(cdnaFrame, proteinFrame); + ClassicJInternalFrame splitFrame = new SplitFrame(cdnaFrame, proteinFrame); Desktop.addInternalFrame(splitFrame, linkedTitle, -1, -1); return proteinFrame.viewport.getAlignment(); diff --git a/src/jalview/gui/AnnotationChooser.java b/src/jalview/gui/AnnotationChooser.java index 791421d..e394374 100644 --- a/src/jalview/gui/AnnotationChooser.java +++ b/src/jalview/gui/AnnotationChooser.java @@ -41,7 +41,7 @@ import java.util.List; import java.util.Map; import javax.swing.JButton; -import javax.swing.JInternalFrame; +import jalview.jbgui.ClassicJInternalFrame; import javax.swing.JLayeredPane; import javax.swing.JPanel; @@ -63,7 +63,7 @@ public class AnnotationChooser extends JPanel private static final int MY_FRAME_HEIGHT = 250; - private JInternalFrame frame; + private ClassicJInternalFrame frame; private AlignmentPanel ap; @@ -601,7 +601,7 @@ public class AnnotationChooser extends JPanel */ private void showFrame() { - frame = new JInternalFrame(); + frame = new ClassicJInternalFrame(); frame.setContentPane(this); frame.setLayer(JLayeredPane.PALETTE_LAYER); Desktop.addInternalFrame(frame, diff --git a/src/jalview/gui/AnnotationColourChooser.java b/src/jalview/gui/AnnotationColourChooser.java index 4e9a26d..71fc719 100644 --- a/src/jalview/gui/AnnotationColourChooser.java +++ b/src/jalview/gui/AnnotationColourChooser.java @@ -44,7 +44,7 @@ import javax.swing.BorderFactory; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JComboBox; -import javax.swing.JInternalFrame; +import jalview.jbgui.ClassicJInternalFrame; import javax.swing.JLayeredPane; import javax.swing.JPanel; @@ -86,7 +86,7 @@ public class AnnotationColourChooser extends AnnotationRowFilter } } } - frame = new JInternalFrame(); + frame = new ClassicJInternalFrame(); frame.setContentPane(this); frame.setLayer(JLayeredPane.PALETTE_LAYER); Desktop.addInternalFrame(frame, diff --git a/src/jalview/gui/AnnotationColumnChooser.java b/src/jalview/gui/AnnotationColumnChooser.java index c0d4708..ccb2bdc 100644 --- a/src/jalview/gui/AnnotationColumnChooser.java +++ b/src/jalview/gui/AnnotationColumnChooser.java @@ -44,7 +44,7 @@ import java.awt.event.KeyEvent; import javax.swing.ButtonGroup; import javax.swing.JCheckBox; import javax.swing.JComboBox; -import javax.swing.JInternalFrame; +import jalview.jbgui.ClassicJInternalFrame; import javax.swing.JLayeredPane; import javax.swing.JPanel; import javax.swing.JRadioButton; @@ -97,7 +97,7 @@ public class AnnotationColumnChooser extends AnnotationRowFilter public AnnotationColumnChooser(AlignViewport av, final AlignmentPanel ap) { super(av, ap); - frame = new JInternalFrame(); + frame = new ClassicJInternalFrame(); frame.setContentPane(this); frame.setLayer(JLayeredPane.PALETTE_LAYER); Desktop.addInternalFrame(frame, diff --git a/src/jalview/gui/AnnotationExporter.java b/src/jalview/gui/AnnotationExporter.java index 1efd100..96fa6fc 100644 --- a/src/jalview/gui/AnnotationExporter.java +++ b/src/jalview/gui/AnnotationExporter.java @@ -43,7 +43,7 @@ import javax.swing.BoxLayout; import javax.swing.ButtonGroup; import javax.swing.JButton; import javax.swing.JCheckBox; -import javax.swing.JInternalFrame; +import jalview.jbgui.ClassicJInternalFrame; import javax.swing.JLabel; import javax.swing.JLayeredPane; import javax.swing.JPanel; @@ -60,7 +60,7 @@ import javax.swing.SwingConstants; */ public class AnnotationExporter extends JPanel { - private JInternalFrame frame; + private ClassicJInternalFrame frame; private AlignmentPanel ap; @@ -107,7 +107,7 @@ public class AnnotationExporter extends JPanel ex.printStackTrace(); } - frame = new JInternalFrame(); + frame = new ClassicJInternalFrame(); frame.setContentPane(this); frame.setLayer(JLayeredPane.PALETTE_LAYER); Dimension preferredSize = frame.getPreferredSize(); diff --git a/src/jalview/gui/AnnotationRowFilter.java b/src/jalview/gui/AnnotationRowFilter.java index 44a1668..a0abe71 100644 --- a/src/jalview/gui/AnnotationRowFilter.java +++ b/src/jalview/gui/AnnotationRowFilter.java @@ -44,7 +44,7 @@ import java.util.Vector; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JComboBox; -import javax.swing.JInternalFrame; +import jalview.jbgui.ClassicJInternalFrame; import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.event.ChangeEvent; @@ -73,7 +73,7 @@ public abstract class AnnotationRowFilter extends JPanel protected JTextField thresholdValue = new JTextField(20); - protected JInternalFrame frame; + protected ClassicJInternalFrame frame; protected JButton ok = new JButton(); diff --git a/src/jalview/gui/AppVarna.java b/src/jalview/gui/AppVarna.java index 3a64716..353bd7a 100644 --- a/src/jalview/gui/AppVarna.java +++ b/src/jalview/gui/AppVarna.java @@ -45,7 +45,7 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import javax.swing.JInternalFrame; +import jalview.jbgui.ClassicJInternalFrame; import javax.swing.JSplitPane; import javax.swing.event.InternalFrameAdapter; import javax.swing.event.InternalFrameEvent; @@ -61,7 +61,7 @@ import fr.orsay.lri.varna.models.annotations.HighlightRegionAnnotation; import fr.orsay.lri.varna.models.rna.ModeleBase; import fr.orsay.lri.varna.models.rna.RNA; -public class AppVarna extends JInternalFrame +public class AppVarna extends ClassicJInternalFrame implements SelectionListener, SecondaryStructureListener, InterfaceVARNASelectionListener, VamsasSource { diff --git a/src/jalview/gui/AquaInternalFrameManager.java b/src/jalview/gui/AquaInternalFrameManager.java index 8ef204c..0433ced 100644 --- a/src/jalview/gui/AquaInternalFrameManager.java +++ b/src/jalview/gui/AquaInternalFrameManager.java @@ -33,6 +33,8 @@ import javax.swing.DefaultDesktopManager; import javax.swing.DesktopManager; import javax.swing.JInternalFrame; +import jalview.jbgui.ClassicJInternalFrame; + /** * Based on AquaInternalFrameManager * @@ -69,9 +71,9 @@ public class AquaInternalFrameManager extends DefaultDesktopManager /* The frame which is currently selected/activated. * We store this value to enforce Mac's single-selection model. */ - JInternalFrame fCurrentFrame; + ClassicJInternalFrame fCurrentFrame; - JInternalFrame fInitialFrame; + ClassicJInternalFrame fInitialFrame; /* The list of frames, sorted by order of creation. * This list is necessary because by default the order of @@ -80,7 +82,7 @@ public class AquaInternalFrameManager extends DefaultDesktopManager * We preserve the creation order so that "next" and "previous" * frame actions make sense. */ - Vector fChildFrames = new Vector<>(1); + Vector fChildFrames = new Vector<>(1); /** * keep a reference to the original LAF manager so we can iconise/de-iconise @@ -116,7 +118,7 @@ public class AquaInternalFrameManager extends DefaultDesktopManager @Override public void deiconifyFrame(final JInternalFrame f) { - JInternalFrame.JDesktopIcon desktopIcon; + ClassicJInternalFrame.JDesktopIcon desktopIcon; desktopIcon = f.getDesktopIcon(); // If the icon moved, move the frame to that spot before expanding it @@ -127,7 +129,7 @@ public class AquaInternalFrameManager extends DefaultDesktopManager } void addIcon(final Container c, - final JInternalFrame.JDesktopIcon desktopIcon) + final ClassicJInternalFrame.JDesktopIcon desktopIcon) { c.add(desktopIcon); } @@ -157,7 +159,7 @@ public class AquaInternalFrameManager extends DefaultDesktopManager { fChildFrames.remove(f); } - fChildFrames.addElement(f); + fChildFrames.addElement((ClassicJInternalFrame) f); if (fCurrentFrame != null && f != fCurrentFrame) { @@ -172,7 +174,7 @@ public class AquaInternalFrameManager extends DefaultDesktopManager f.setSelected(true); } - fCurrentFrame = f; + fCurrentFrame = (ClassicJInternalFrame) f; } catch (final PropertyVetoException e) { } @@ -222,13 +224,13 @@ public class AquaInternalFrameManager extends DefaultDesktopManager nextIndex = count - 1; } } - final JInternalFrame f = fChildFrames.elementAt(nextIndex); + final ClassicJInternalFrame f = fChildFrames.elementAt(nextIndex); activateFrame(f); fCurrentFrame = f; } /** - * Activate the next child JInternalFrame, as determined by the frames' + * Activate the next child ClassicJInternalFrame, as determined by the frames' * Z-order. If there is only one child frame, it remains activated. If there * are no child frames, nothing happens. */ @@ -240,16 +242,16 @@ public class AquaInternalFrameManager extends DefaultDesktopManager /** * same as above but will activate a frame if none have been selected */ - public void activateNextFrame(final JInternalFrame f) + public void activateNextFrame(final ClassicJInternalFrame f) { fInitialFrame = f; switchFrame(true); } /** - * Activate the previous child JInternalFrame, as determined by the frames' - * Z-order. If there is only one child frame, it remains activated. If there - * are no child frames, nothing happens. + * Activate the previous child ClassicJInternalFrame, as determined by the + * frames' Z-order. If there is only one child frame, it remains activated. If + * there are no child frames, nothing happens. */ public void activatePreviousFrame() { diff --git a/src/jalview/gui/CalculationChooser.java b/src/jalview/gui/CalculationChooser.java index f7e5413..9926cfe 100644 --- a/src/jalview/gui/CalculationChooser.java +++ b/src/jalview/gui/CalculationChooser.java @@ -53,7 +53,7 @@ import javax.swing.DefaultComboBoxModel; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JComboBox; -import javax.swing.JInternalFrame; +import jalview.jbgui.ClassicJInternalFrame; import javax.swing.JLabel; import javax.swing.JLayeredPane; import javax.swing.JPanel; @@ -92,7 +92,7 @@ public class CalculationChooser extends JPanel JButton calculate; - private JInternalFrame frame; + private ClassicJInternalFrame frame; private JCheckBox includeGaps; @@ -129,7 +129,7 @@ public class CalculationChooser extends JPanel void init() { setLayout(new BorderLayout()); - frame = new JInternalFrame(); + frame = new ClassicJInternalFrame(); frame.setContentPane(this); this.setBackground(Color.white); frame.addFocusListener(new FocusListener() diff --git a/src/jalview/gui/ChimeraViewFrame.java b/src/jalview/gui/ChimeraViewFrame.java index cc6a785..55f14ea 100644 --- a/src/jalview/gui/ChimeraViewFrame.java +++ b/src/jalview/gui/ChimeraViewFrame.java @@ -30,7 +30,7 @@ import java.util.Collections; import java.util.List; import java.util.Map; -import javax.swing.JInternalFrame; +import jalview.jbgui.ClassicJInternalFrame; import javax.swing.JMenu; import javax.swing.JMenuItem; import javax.swing.event.InternalFrameAdapter; @@ -312,7 +312,7 @@ public class ChimeraViewFrame extends StructureViewerBase * closeViewer will decide whether or not to close this frame * depending on whether user chooses to Cancel or not */ - setDefaultCloseOperation(JInternalFrame.DO_NOTHING_ON_CLOSE); + setDefaultCloseOperation(ClassicJInternalFrame.DO_NOTHING_ON_CLOSE); } /** diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index ccfb1d2..c713145 100644 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -113,6 +113,7 @@ import jalview.io.FormatAdapter; import jalview.io.IdentifyFile; import jalview.io.JalviewFileChooser; import jalview.io.JalviewFileView; +import jalview.jbgui.ClassicJInternalFrame; import jalview.jbgui.GSplitFrame; import jalview.jbgui.GStructureViewer; import jalview.project.Jalview2XML; @@ -493,7 +494,7 @@ public class Desktop extends jalview.jbgui.GDesktop // sp.getViewport().setView(desktop); // getContentPane().add(sp, BorderLayout.CENTER); - // BH 2018 - just an experiment to try unclipped JInternalFrames. + // BH 2018 - just an experiment to try unclipped ClassicJInternalFrames. if (Platform.isJS()) { getRootPane().putClientProperty("swingjs.overflow.hidden", "false"); @@ -842,7 +843,7 @@ public class Desktop extends jalview.jbgui.GDesktop * height */ public static synchronized void addInternalFrame( - final JInternalFrame frame, String title, int w, int h) + final ClassicJInternalFrame frame, String title, int w, int h) { addInternalFrame(frame, title, true, w, h, true, false); } @@ -863,8 +864,8 @@ public class Desktop extends jalview.jbgui.GDesktop * height */ public static synchronized void addInternalFrame( - final JInternalFrame frame, String title, boolean makeVisible, - int w, int h) + final ClassicJInternalFrame frame, String title, + boolean makeVisible, int w, int h) { addInternalFrame(frame, title, makeVisible, w, h, true, false); } @@ -884,7 +885,7 @@ public class Desktop extends jalview.jbgui.GDesktop * Allow resize */ public static synchronized void addInternalFrame( - final JInternalFrame frame, String title, int w, int h, + final ClassicJInternalFrame frame, String title, int w, int h, boolean resizable) { addInternalFrame(frame, title, true, w, h, resizable, false); @@ -910,8 +911,9 @@ public class Desktop extends jalview.jbgui.GDesktop * Do not set the default minimum size for frame */ public static synchronized void addInternalFrame( - final JInternalFrame frame, String title, boolean makeVisible, - int w, int h, boolean resizable, boolean ignoreMinSize) + final ClassicJInternalFrame frame, String title, + boolean makeVisible, int w, int h, boolean resizable, + boolean ignoreMinSize) { // TODO: allow callers to determine X and Y position of frame (eg. via @@ -975,7 +977,7 @@ public class Desktop extends jalview.jbgui.GDesktop @Override public void internalFrameActivated(InternalFrameEvent evt) { - JInternalFrame itf = desktop.getSelectedFrame(); + ClassicJInternalFrame itf = desktop.getSelectedFrame(); if (itf != null) { if (itf instanceof AlignFrame) @@ -1048,12 +1050,12 @@ public class Desktop extends jalview.jbgui.GDesktop } /** - * Add key bindings to a JInternalFrame so that Ctrl-W and Cmd-W will close - * the window + * Add key bindings to a ClassicJInternalFrame so that Ctrl-W and Cmd-W will + * close the window * * @param frame */ - private static void setKeyBindings(JInternalFrame frame) + private static void setKeyBindings(ClassicJInternalFrame frame) { @SuppressWarnings("serial") final Action closeAction = new AbstractAction() @@ -1524,7 +1526,7 @@ public class Desktop extends jalview.jbgui.GDesktop public void closeAll_actionPerformed(ActionEvent e) { // TODO show a progress bar while closing? - JInternalFrame[] frames = desktop.getAllFrames(); + ClassicJInternalFrame[] frames = desktop.getAllFrames(); for (int i = 0; i < frames.length; i++) { try @@ -1627,7 +1629,7 @@ public class Desktop extends jalview.jbgui.GDesktop void reorderAssociatedWindows(boolean minimize, boolean close) { - JInternalFrame[] frames = desktop.getAllFrames(); + ClassicJInternalFrame[] frames = desktop.getAllFrames(); if (frames == null || frames.length < 1) { return; @@ -2127,7 +2129,7 @@ public class Desktop extends jalview.jbgui.GDesktop { source.viewport.setGatherViewsHere(true); source.viewport.setExplodedGeometry(source.getBounds()); - JInternalFrame[] frames = desktop.getAllFrames(); + ClassicJInternalFrame[] frames = desktop.getAllFrames(); String viewId = source.viewport.getSequenceSetId(); for (int t = 0; t < frames.length; t++) { @@ -2178,7 +2180,7 @@ public class Desktop extends jalview.jbgui.GDesktop } - public JInternalFrame[] getAllFrames() + public ClassicJInternalFrame[] getAllFrames() { return desktop.getAllFrames(); } @@ -2373,6 +2375,16 @@ public class Desktop extends jalview.jbgui.GDesktop // output debug scale message. Important for jalview.bin.HiDPISettingTest2 Desktop.debugScaleMessage(Desktop.getDesktop().getGraphics()); } + + public ClassicJInternalFrame getSelectedFrame() + { + return (ClassicJInternalFrame) super.getSelectedFrame(); + } + + public ClassicJInternalFrame[] getAllFrames() + { + return (ClassicJInternalFrame[]) super.getAllFrames(); + } } /** @@ -2388,7 +2400,7 @@ public class Desktop extends jalview.jbgui.GDesktop return new AlignFrame[] { Jalview.currentAlignFrame }; } - JInternalFrame[] frames = Desktop.desktop.getAllFrames(); + ClassicJInternalFrame[] frames = Desktop.desktop.getAllFrames(); if (frames == null) { @@ -2433,7 +2445,7 @@ public class Desktop extends jalview.jbgui.GDesktop */ public GStructureViewer[] getJmols() { - JInternalFrame[] frames = Desktop.desktop.getAllFrames(); + ClassicJInternalFrame[] frames = Desktop.desktop.getAllFrames(); if (frames == null) { @@ -3110,7 +3122,7 @@ public class Desktop extends jalview.jbgui.GDesktop topPanel.av.setGatherViewsHere(false); bottomPanel.av.setGatherViewsHere(false); - JInternalFrame splitFrame = new SplitFrame(newTopFrame, + ClassicJInternalFrame splitFrame = new SplitFrame(newTopFrame, newBottomFrame); if (geometry != null) { @@ -3154,8 +3166,9 @@ public class Desktop extends jalview.jbgui.GDesktop String topViewId = myTopFrame.viewport.getSequenceSetId(); String bottomViewId = myBottomFrame.viewport.getSequenceSetId(); - JInternalFrame[] frames = desktop.getAllFrames(); - for (JInternalFrame frame : frames) + ClassicJInternalFrame[] frames = (ClassicJInternalFrame[]) desktop + .getAllFrames(); + for (ClassicJInternalFrame frame : frames) { if (frame instanceof SplitFrame && frame != source) { @@ -3434,9 +3447,9 @@ public class Desktop extends jalview.jbgui.GDesktop Class structureViewerClass) { List result = new ArrayList<>(); - JInternalFrame[] frames = Desktop.instance.getAllFrames(); + ClassicJInternalFrame[] frames = Desktop.instance.getAllFrames(); - for (JInternalFrame frame : frames) + for (ClassicJInternalFrame frame : frames) { if (frame instanceof StructureViewerBase) { diff --git a/src/jalview/gui/FeatureSettings.java b/src/jalview/gui/FeatureSettings.java index bb15b55..4545a99 100644 --- a/src/jalview/gui/FeatureSettings.java +++ b/src/jalview/gui/FeatureSettings.java @@ -64,7 +64,7 @@ import javax.swing.Icon; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JCheckBoxMenuItem; -import javax.swing.JInternalFrame; +import jalview.jbgui.ClassicJInternalFrame; import javax.swing.JLabel; import javax.swing.JLayeredPane; import javax.swing.JMenuItem; @@ -158,7 +158,7 @@ public class FeatureSettings extends JPanel private Map originalFilters; - final JInternalFrame frame; + final ClassicJInternalFrame frame; JScrollPane scrollPane = new JScrollPane(); @@ -411,7 +411,7 @@ public class FeatureSettings extends JPanel } else { - frame = new JInternalFrame(); + frame = new ClassicJInternalFrame(); frame.setContentPane(this); Rectangle bounds = af.getFeatureSettingsGeometry(); String title; diff --git a/src/jalview/gui/Finder.java b/src/jalview/gui/Finder.java index 358d9a4..282aba1 100755 --- a/src/jalview/gui/Finder.java +++ b/src/jalview/gui/Finder.java @@ -36,7 +36,7 @@ import java.util.regex.PatternSyntaxException; import javax.swing.AbstractAction; import javax.swing.JComponent; -import javax.swing.JInternalFrame; +import jalview.jbgui.ClassicJInternalFrame; import javax.swing.JLayeredPane; import javax.swing.KeyStroke; import javax.swing.event.InternalFrameAdapter; @@ -76,7 +76,7 @@ public class Finder extends GFinder private AlignmentPanel ap; - private JInternalFrame frame; + private ClassicJInternalFrame frame; /* * Finder agent per viewport searched @@ -108,7 +108,7 @@ public class Finder extends GFinder ap = alignPanel; focusFixed = fixedFocus; finders = new HashMap<>(); - frame = new JInternalFrame(); + frame = new ClassicJInternalFrame(); frame.setContentPane(this); frame.setLayer(JLayeredPane.PALETTE_LAYER); frame.addInternalFrameListener(new InternalFrameAdapter() @@ -207,10 +207,10 @@ public class Finder extends GFinder } // now checks further down the window stack to fix bug // https://mantis.lifesci.dundee.ac.uk/view.php?id=36008 - JInternalFrame[] frames = Desktop.desktop.getAllFrames(); + ClassicJInternalFrame[] frames = Desktop.desktop.getAllFrames(); for (int f = 0; f < frames.length; f++) { - JInternalFrame alignFrame = frames[f]; + ClassicJInternalFrame alignFrame = frames[f]; if (alignFrame != null && alignFrame instanceof AlignFrame && !alignFrame.isIcon()) { diff --git a/src/jalview/gui/FontChooser.java b/src/jalview/gui/FontChooser.java index 92cc4c6..3728b85 100755 --- a/src/jalview/gui/FontChooser.java +++ b/src/jalview/gui/FontChooser.java @@ -28,7 +28,7 @@ import java.awt.Font; import java.awt.FontMetrics; import java.awt.geom.Rectangle2D; -import javax.swing.JInternalFrame; +import jalview.jbgui.ClassicJInternalFrame; import javax.swing.JLayeredPane; /** @@ -66,7 +66,7 @@ public class FontChooser extends GFontChooser boolean init = true; - JInternalFrame frame; + ClassicJInternalFrame frame; /* * The last font settings selected in the dialog @@ -111,7 +111,7 @@ public class FontChooser extends GFontChooser void init() { - frame = new JInternalFrame(); + frame = new ClassicJInternalFrame(); frame.setContentPane(this); smoothFont.setSelected(ap.av.antiAlias); diff --git a/src/jalview/gui/OverviewPanel.java b/src/jalview/gui/OverviewPanel.java index adde919..f5111b1 100755 --- a/src/jalview/gui/OverviewPanel.java +++ b/src/jalview/gui/OverviewPanel.java @@ -43,7 +43,7 @@ import java.beans.PropertyChangeEvent; import java.beans.PropertyVetoException; import javax.swing.JCheckBoxMenuItem; -import javax.swing.JInternalFrame; +import jalview.jbgui.ClassicJInternalFrame; import javax.swing.JPanel; import javax.swing.JPopupMenu; import javax.swing.SwingUtilities; @@ -407,8 +407,8 @@ public class OverviewPanel extends JPanel * close the parent frame (which also removes it from the * Desktop Windows menu) */ - ((JInternalFrame) SwingUtilities - .getAncestorOfClass(JInternalFrame.class, (this))) + ((ClassicJInternalFrame) SwingUtilities + .getAncestorOfClass(ClassicJInternalFrame.class, (this))) .setClosed(true); } catch (PropertyVetoException e) { diff --git a/src/jalview/gui/PopupMenu.java b/src/jalview/gui/PopupMenu.java index 6903034..25bb15a 100644 --- a/src/jalview/gui/PopupMenu.java +++ b/src/jalview/gui/PopupMenu.java @@ -42,7 +42,7 @@ import java.util.Vector; import javax.swing.ButtonGroup; import javax.swing.JCheckBoxMenuItem; -import javax.swing.JInternalFrame; +import jalview.jbgui.ClassicJInternalFrame; import javax.swing.JLabel; import javax.swing.JMenu; import javax.swing.JMenuItem; @@ -903,10 +903,10 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener protected void showFeatureDetails(SequenceFeature sf, String seqName, MappedFeatures mf) { - JInternalFrame details; + ClassicJInternalFrame details; if (Platform.isJS()) { - details = new JInternalFrame(); + details = new ClassicJInternalFrame(); JPanel panel = new JPanel(new BorderLayout()); panel.setOpaque(true); panel.setBackground(Color.white); @@ -1825,7 +1825,7 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener contents.append(""); String report = contents.toString(); - JInternalFrame frame; + ClassicJInternalFrame frame; if (Platform.isJS()) { JLabel textLabel = new JLabel(); @@ -1835,7 +1835,7 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener pane.setOpaque(true); pane.setBackground(Color.WHITE); pane.add(textLabel, BorderLayout.NORTH); - frame = new JInternalFrame(); + frame = new ClassicJInternalFrame(); frame.getContentPane().add(new JScrollPane(pane)); } else diff --git a/src/jalview/gui/Preferences.java b/src/jalview/gui/Preferences.java index 06d3a60..9d0128a 100755 --- a/src/jalview/gui/Preferences.java +++ b/src/jalview/gui/Preferences.java @@ -34,7 +34,7 @@ import java.util.concurrent.CompletableFuture; import javax.help.HelpSetException; import javax.swing.JComboBox; -import javax.swing.JInternalFrame; +import jalview.jbgui.ClassicJInternalFrame; import javax.swing.JPanel; import javax.swing.ListSelectionModel; import javax.swing.RowFilter; @@ -182,7 +182,7 @@ public class Preferences extends GPreferences groupURLLinks = new ArrayList<>(); } - JInternalFrame frame; + ClassicJInternalFrame frame; private WsPreferences wsPrefs; @@ -248,7 +248,7 @@ public class Preferences extends GPreferences private Preferences() { super(); - frame = new JInternalFrame(); + frame = new ClassicJInternalFrame(); frame.setContentPane(this); if (!Platform.isJS()) /** diff --git a/src/jalview/gui/PymolViewer.java b/src/jalview/gui/PymolViewer.java index 9dc28c8..e23c34b 100644 --- a/src/jalview/gui/PymolViewer.java +++ b/src/jalview/gui/PymolViewer.java @@ -27,7 +27,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; -import javax.swing.JInternalFrame; +import jalview.jbgui.ClassicJInternalFrame; import javax.swing.JMenuItem; import javax.swing.event.InternalFrameAdapter; import javax.swing.event.InternalFrameEvent; @@ -63,7 +63,7 @@ public class PymolViewer extends StructureViewerBase * closeViewer will decide whether or not to close this frame * depending on whether user chooses to Cancel or not */ - setDefaultCloseOperation(JInternalFrame.DO_NOTHING_ON_CLOSE); + setDefaultCloseOperation(ClassicJInternalFrame.DO_NOTHING_ON_CLOSE); } public PymolViewer(PDBEntry pdb, SequenceI[] seqs, Object object, diff --git a/src/jalview/gui/RedundancyPanel.java b/src/jalview/gui/RedundancyPanel.java index 6ed3248..f2f36f5 100755 --- a/src/jalview/gui/RedundancyPanel.java +++ b/src/jalview/gui/RedundancyPanel.java @@ -35,7 +35,7 @@ import java.util.List; import java.util.Stack; import java.util.Vector; -import javax.swing.JInternalFrame; +import jalview.jbgui.ClassicJInternalFrame; import javax.swing.JProgressBar; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; @@ -62,7 +62,7 @@ public class RedundancyPanel extends GSliderPanel implements Runnable SequenceI[] originalSequences; - JInternalFrame frame; + ClassicJInternalFrame frame; Vector redundantSeqs; @@ -99,7 +99,7 @@ public class RedundancyPanel extends GSliderPanel implements Runnable Thread worker = new Thread(this); worker.start(); - frame = new JInternalFrame(); + frame = new ClassicJInternalFrame(); frame.setContentPane(this); Desktop.addInternalFrame(frame, MessageManager diff --git a/src/jalview/gui/SequenceFetcher.java b/src/jalview/gui/SequenceFetcher.java index e596fbf..9516fb6 100755 --- a/src/jalview/gui/SequenceFetcher.java +++ b/src/jalview/gui/SequenceFetcher.java @@ -35,7 +35,7 @@ import java.util.List; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JComboBox; -import javax.swing.JInternalFrame; +import jalview.jbgui.ClassicJInternalFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; @@ -125,7 +125,7 @@ public class SequenceFetcher extends JPanel implements Runnable JTextArea textArea; - JInternalFrame frame; + ClassicJInternalFrame frame; IProgressIndicator guiWindow; @@ -184,7 +184,7 @@ public class SequenceFetcher extends JPanel implements Runnable jbInit(selectedDb); textArea.setText(queryString); - frame = new JInternalFrame(); + frame = new ClassicJInternalFrame(); frame.setContentPane(this); Desktop.addInternalFrame(frame, getFrameTitle(), true, 400, Platform.isAMacAndNotJS() ? 240 : 180); diff --git a/src/jalview/gui/SliderPanel.java b/src/jalview/gui/SliderPanel.java index 46b47a2..8649377 100755 --- a/src/jalview/gui/SliderPanel.java +++ b/src/jalview/gui/SliderPanel.java @@ -32,7 +32,7 @@ import java.awt.event.MouseEvent; import java.beans.PropertyVetoException; import java.util.List; -import javax.swing.JInternalFrame; +import jalview.jbgui.ClassicJInternalFrame; import javax.swing.JLayeredPane; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; @@ -49,9 +49,9 @@ public class SliderPanel extends GSliderPanel { private static final String BACKGROUND = "Background"; - static JInternalFrame conservationSlider; + static ClassicJInternalFrame conservationSlider; - static JInternalFrame PIDSlider; + static ClassicJInternalFrame PIDSlider; AlignmentPanel ap; @@ -156,7 +156,7 @@ public class SliderPanel extends GSliderPanel if (conservationSlider == null) { sliderPanel = new SliderPanel(ap, rs.getConservationInc(), true, rs); - conservationSlider = new JInternalFrame(); + conservationSlider = new ClassicJInternalFrame(); conservationSlider.setContentPane(sliderPanel); conservationSlider.setLayer(JLayeredPane.PALETTE_LAYER); } @@ -267,7 +267,7 @@ public class SliderPanel extends GSliderPanel if (PIDSlider == null) { sliderPanel = new SliderPanel(ap, threshold, false, rs); - PIDSlider = new JInternalFrame(); + PIDSlider = new ClassicJInternalFrame(); PIDSlider.setContentPane(sliderPanel); PIDSlider.setLayer(JLayeredPane.PALETTE_LAYER); } @@ -301,7 +301,7 @@ public class SliderPanel extends GSliderPanel * * @return */ - public static JInternalFrame showPIDSlider() + public static ClassicJInternalFrame showPIDSlider() { hideConservationSlider(); @@ -454,7 +454,7 @@ public class SliderPanel extends GSliderPanel return getValue(conservationSlider); } - static int getValue(JInternalFrame slider) + static int getValue(ClassicJInternalFrame slider) { return slider == null ? 0 : ((SliderPanel) slider.getContentPane()).getValue(); diff --git a/src/jalview/gui/SplashScreen.java b/src/jalview/gui/SplashScreen.java index 61273c7..5fe69de 100755 --- a/src/jalview/gui/SplashScreen.java +++ b/src/jalview/gui/SplashScreen.java @@ -31,7 +31,7 @@ import java.awt.MediaTracker; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import javax.swing.JInternalFrame; +import jalview.jbgui.ClassicJInternalFrame; import javax.swing.JLabel; import javax.swing.JLayeredPane; import javax.swing.JPanel; @@ -72,7 +72,7 @@ public class SplashScreen extends JPanel */ private Component splashText; - private JInternalFrame iframe; + private ClassicJInternalFrame iframe; private Image image; @@ -184,7 +184,7 @@ public class SplashScreen extends JPanel this.setForeground(fg); this.setFont(font); - iframe = new JInternalFrame(); + iframe = new ClassicJInternalFrame(); iframe.setFrameIcon(null); iframe.setClosable(true); this.setLayout(new BorderLayout()); diff --git a/src/jalview/gui/SplitFrame.java b/src/jalview/gui/SplitFrame.java index 6ebedb7..5187402 100644 --- a/src/jalview/gui/SplitFrame.java +++ b/src/jalview/gui/SplitFrame.java @@ -38,7 +38,6 @@ import javax.swing.InputMap; import javax.swing.JButton; import javax.swing.JComponent; import javax.swing.JDesktopPane; -import javax.swing.JInternalFrame; import javax.swing.JLayeredPane; import javax.swing.JMenuItem; import javax.swing.JPanel; @@ -54,6 +53,7 @@ import jalview.api.FeatureSettingsControllerI; import jalview.api.SplitContainerI; import jalview.controller.FeatureSettingsControllerGuiI; import jalview.datamodel.AlignmentI; +import jalview.jbgui.ClassicJInternalFrame; import jalview.jbgui.GAlignFrame; import jalview.jbgui.GSplitFrame; import jalview.structure.StructureSelectionManager; @@ -838,8 +838,8 @@ public class SplitFrame extends GSplitFrame implements SplitContainerI public void setSelected(boolean selected) throws PropertyVetoException { JDesktopPane desktopPane = getDesktopPane(); - JInternalFrame fr = desktopPane == null ? null - : desktopPane.getSelectedFrame(); + ClassicJInternalFrame fr = desktopPane == null ? null + : (ClassicJInternalFrame) desktopPane.getSelectedFrame(); if (fr == getTopFrame() || fr == getBottomFrame()) { /* @@ -860,7 +860,7 @@ public class SplitFrame extends GSplitFrame implements SplitContainerI * holds the frame for feature settings, so Protein and DNA tabs can be * managed */ - JInternalFrame featureSettingsUI; + ClassicJInternalFrame featureSettingsUI; JTabbedPane featureSettingsPanels; @@ -897,8 +897,9 @@ public class SplitFrame extends GSplitFrame implements SplitContainerI getAlignFrames().get(tab).showFeatureSettingsUI(); } }); - featureSettingsUI = new JInternalFrame(MessageManager.getString( - "label.sequence_feature_settings_for_CDS_and_Protein")); + featureSettingsUI = new ClassicJInternalFrame( + MessageManager.getString( + "label.sequence_feature_settings_for_CDS_and_Protein")); featureSettingsPanels.setOpaque(true); JPanel dialog = new JPanel(); diff --git a/src/jalview/gui/UserDefinedColours.java b/src/jalview/gui/UserDefinedColours.java index 1836e33..e2bcf6f 100755 --- a/src/jalview/gui/UserDefinedColours.java +++ b/src/jalview/gui/UserDefinedColours.java @@ -52,7 +52,7 @@ import java.util.ArrayList; import java.util.List; import javax.swing.JButton; -import javax.swing.JInternalFrame; +import jalview.jbgui.ClassicJInternalFrame; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.xml.bind.JAXBContext; @@ -95,7 +95,7 @@ public class UserDefinedColours extends GUserDefinedColours */ boolean changedButNotSaved; - JInternalFrame frame; + ClassicJInternalFrame frame; List upperCaseButtons; @@ -148,7 +148,7 @@ public class UserDefinedColours extends GUserDefinedColours void showFrame() { colorChooser.getSelectionModel().addChangeListener(this); - frame = new JInternalFrame(); + frame = new ClassicJInternalFrame(); frame.setContentPane(this); Desktop.addInternalFrame(frame, MessageManager.getString("label.user_defined_colours"), diff --git a/src/jalview/gui/VamsasApplication.java b/src/jalview/gui/VamsasApplication.java index 8a8ba8d..c9576c7 100644 --- a/src/jalview/gui/VamsasApplication.java +++ b/src/jalview/gui/VamsasApplication.java @@ -44,7 +44,7 @@ import java.util.Hashtable; import java.util.IdentityHashMap; import java.util.Iterator; -import javax.swing.JInternalFrame; +import jalview.jbgui.ClassicJInternalFrame; import uk.ac.vamsas.client.ClientHandle; import uk.ac.vamsas.client.IClient; @@ -285,7 +285,7 @@ public class VamsasApplication implements SelectionSource, VamsasSource */ protected void updateJalviewGui() { - JInternalFrame[] frames = jdesktop.getAllFrames(); + ClassicJInternalFrame[] frames = jdesktop.getAllFrames(); if (frames == null) { @@ -453,7 +453,7 @@ public class VamsasApplication implements SelectionSource, VamsasSource VamsasAppDatastore vds = new VamsasAppDatastore(doc, vobj2jv, jv2vobj, baseProvEntry(), alRedoState); // wander through frames - JInternalFrame[] frames = Desktop.desktop.getAllFrames(); + ClassicJInternalFrame[] frames = Desktop.desktop.getAllFrames(); if (frames == null) { diff --git a/src/jalview/gui/WebserviceInfo.java b/src/jalview/gui/WebserviceInfo.java index ee1b473..e5568d4 100644 --- a/src/jalview/gui/WebserviceInfo.java +++ b/src/jalview/gui/WebserviceInfo.java @@ -37,7 +37,7 @@ import java.util.Vector; import javax.swing.JComponent; import javax.swing.JEditorPane; -import javax.swing.JInternalFrame; +import jalview.jbgui.ClassicJInternalFrame; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTabbedPane; @@ -95,7 +95,7 @@ public class WebserviceInfo extends GWebserviceInfo boolean serviceIsCancellable; - JInternalFrame frame; + ClassicJInternalFrame frame; private IProgressIndicator progressBar; @@ -323,7 +323,7 @@ public class WebserviceInfo extends GWebserviceInfo void init(String title, String info, int width, int height, boolean makeVisible) { - frame = new JInternalFrame(); + frame = new ClassicJInternalFrame(); frame.setContentPane(this); Desktop.addInternalFrame(frame, title, makeVisible, width, height); frame.setClosable(false); diff --git a/src/jalview/io/VamsasAppDatastore.java b/src/jalview/io/VamsasAppDatastore.java index dd4b72c..3cd116d 100644 --- a/src/jalview/io/VamsasAppDatastore.java +++ b/src/jalview/io/VamsasAppDatastore.java @@ -720,7 +720,7 @@ public class VamsasAppDatastore // FIND ANY ASSOCIATED TREES if (Desktop.desktop != null) { - javax.swing.JInternalFrame[] frames = Desktop.instance + jalview.jbgui.ClassicJInternalFrame[] frames = Desktop.instance .getAllFrames(); for (int t = 0; t < frames.length; t++) diff --git a/src/jalview/jbgui/ClassicJInternalFrame.java b/src/jalview/jbgui/ClassicJInternalFrame.java new file mode 100644 index 0000000..bdf100a --- /dev/null +++ b/src/jalview/jbgui/ClassicJInternalFrame.java @@ -0,0 +1,143 @@ +package jalview.jbgui; + +/* + * bsoares 2022-04-18 + * ClassicJInternalFrame is a hacked fix for ClassicJInternalFrame's menu (and JComboBox) + * widgets not retaining focus when clicked on prior to the frame having focus (e.g. + * if another frame has focus and you click on the menu of an unfocused frame then + * the menu doesn't open (or more accurately does open and immediately closes again). + * This is well documented Java 11+ behaviour, see + * https://bugs.openjdk.java.net/browse/JDK-8274931 + * A workaround is to reinstate the old setSelected() and dispose() methods that do + * not send out an ungrab event. This is taken from + * https://github.com/george-hawkins/jinternalframe-bug/blob/main/src/main/java/com/example/InternalFrameBugFixDemo.java + * + * We now extend GAlignFrame from jalview.jbgui.ClassicJInternalFrame. + */ + +import java.beans.BeanProperty; +import java.beans.PropertyVetoException; + +import javax.swing.JInternalFrame; +import javax.swing.event.InternalFrameEvent; + +public class ClassicJInternalFrame extends JInternalFrame +{ + public ClassicJInternalFrame() + { + super(); + } + + public ClassicJInternalFrame(String title) + { + super(title); + } + + public ClassicJInternalFrame(String title, boolean resizable) + { + super(title, resizable); + } + + public ClassicJInternalFrame(String title, boolean resizable, + boolean closable) + { + super(title, resizable, closable); + } + + public ClassicJInternalFrame(String title, boolean resizable, + boolean closable, boolean maximizable) + { + super(title, resizable, closable, maximizable); + } + + public ClassicJInternalFrame(String title, boolean resizable, + boolean closable, boolean maximizable, boolean iconifiable) + { + super(title, resizable, closable, maximizable, iconifiable); + } + + // ----------------------------------------------------------------- + + // The two methods below, `setSelected` and `dispose`, are copied from + // `ClassicJInternalFrame` as it existed here: + // https://github.com/openjdk/jdk/blob/jdk-11%2B12/src/java.desktop/share/classes/jalview.jbgui.ClassicJInternalFrame.java + // They've then been modified to back out this change: + // https://github.com/openjdk/jdk/commit/4b8cfe5a6058cdada1ad6efbb8f81e2f8f53a177 + // The ticket for that change is + // https://bugs.openjdk.java.net/browse/JDK-8173739 + // + // On moving to Java 11 we found that if you had two windows, A and B, where A + // currently has focus and + // B has a combo-box, if you click on the combo-box of B you see the combo's + // dropdown list appear + // and then immediately disappear - the trigger for this disappearance is an + // ungrab events generated + // by A, i.e. the window losing focus as a result of you clicking on a + // component in window B. + // The generation of ungrab events in this situation was introduced in the + // change linked to above. + + @BeanProperty( + description = "Indicates whether this internal frame is currently the active frame.") + public void setSelected(boolean selected) throws PropertyVetoException + { + // The InternalFrame may already be selected, but the focus + // may be outside it, so restore the focus to the subcomponent + // which previously had it. See Bug 4302764. + if (selected && isSelected) + { + restoreSubcomponentFocus(); + return; + } + // The internal frame or the desktop icon must be showing to allow + // selection. We may deselect even if neither is showing. + if ((isSelected == selected) || (selected + && (isIcon ? !desktopIcon.isShowing() : !isShowing()))) + { + return; + } + + Boolean oldValue = isSelected ? Boolean.TRUE : Boolean.FALSE; + Boolean newValue = selected ? Boolean.TRUE : Boolean.FALSE; + fireVetoableChange(IS_SELECTED_PROPERTY, oldValue, newValue); + + /* We don't want to leave focus in the previously selected + frame, so we have to set it to *something* in case it + doesn't get set in some other way (as if a user clicked on + a component that doesn't request focus). If this call is + happening because the user clicked on a component that will + want focus, then it will get transfered there later. + We test for parent.isShowing() above, because AWT throws a + NPE if you try to request focus on a lightweight before its + parent has been made visible */ + + if (selected) + { + restoreSubcomponentFocus(); + } + + isSelected = selected; + firePropertyChange(IS_SELECTED_PROPERTY, oldValue, newValue); + if (isSelected) + fireInternalFrameEvent(InternalFrameEvent.INTERNAL_FRAME_ACTIVATED); + else + { + fireInternalFrameEvent(InternalFrameEvent.INTERNAL_FRAME_DEACTIVATED); + } + repaint(); + } + + public void dispose() + { + if (isVisible()) + { + setVisible(false); + } + if (!isClosed) + { + firePropertyChange(IS_CLOSED_PROPERTY, Boolean.FALSE, Boolean.TRUE); + isClosed = true; + } + fireInternalFrameEvent(InternalFrameEvent.INTERNAL_FRAME_CLOSED); + } +} diff --git a/src/jalview/jbgui/GAlignFrame.java b/src/jalview/jbgui/GAlignFrame.java index 71b6b9e..3d17b5b 100755 --- a/src/jalview/jbgui/GAlignFrame.java +++ b/src/jalview/jbgui/GAlignFrame.java @@ -20,18 +20,6 @@ */ package jalview.jbgui; -import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder; -import jalview.analysis.GeneticCodeI; -import jalview.analysis.GeneticCodes; -import jalview.api.SplitContainerI; -import jalview.bin.Cache; -import jalview.gui.JvSwingUtils; -import jalview.gui.Preferences; -import jalview.io.FileFormats; -import jalview.schemes.ResidueColourScheme; -import jalview.util.MessageManager; -import jalview.util.Platform; - import java.awt.BorderLayout; import java.awt.Color; import java.awt.GridLayout; @@ -48,7 +36,6 @@ import java.util.Map; import javax.swing.BorderFactory; import javax.swing.ButtonGroup; import javax.swing.JCheckBoxMenuItem; -import javax.swing.JInternalFrame; import javax.swing.JLabel; import javax.swing.JMenu; import javax.swing.JMenuBar; @@ -61,8 +48,20 @@ import javax.swing.event.ChangeEvent; import javax.swing.event.MenuEvent; import javax.swing.event.MenuListener; +import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder; +import jalview.analysis.GeneticCodeI; +import jalview.analysis.GeneticCodes; +import jalview.api.SplitContainerI; +import jalview.bin.Cache; +import jalview.gui.JvSwingUtils; +import jalview.gui.Preferences; +import jalview.io.FileFormats; +import jalview.schemes.ResidueColourScheme; +import jalview.util.MessageManager; +import jalview.util.Platform; + @SuppressWarnings("serial") -public class GAlignFrame extends JInternalFrame +public class GAlignFrame extends ClassicJInternalFrame { protected JMenuBar alignFrameMenuBar = new JMenuBar(); diff --git a/src/jalview/jbgui/GCutAndPasteHtmlTransfer.java b/src/jalview/jbgui/GCutAndPasteHtmlTransfer.java index ad1c1cf..bdbbfe7 100644 --- a/src/jalview/jbgui/GCutAndPasteHtmlTransfer.java +++ b/src/jalview/jbgui/GCutAndPasteHtmlTransfer.java @@ -32,7 +32,7 @@ import java.awt.event.MouseEvent; import javax.swing.JButton; import javax.swing.JCheckBoxMenuItem; import javax.swing.JEditorPane; -import javax.swing.JInternalFrame; +import jalview.jbgui.ClassicJInternalFrame; import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JMenuItem; @@ -47,7 +47,7 @@ import javax.swing.text.html.HTMLEditorKit; * @author $author$ * @version $Revision$ */ -public class GCutAndPasteHtmlTransfer extends JInternalFrame +public class GCutAndPasteHtmlTransfer extends ClassicJInternalFrame { protected JEditorPane textarea = new JEditorPane("text/html", ""); diff --git a/src/jalview/jbgui/GCutAndPasteTransfer.java b/src/jalview/jbgui/GCutAndPasteTransfer.java index b75dd8c..bccc798 100755 --- a/src/jalview/jbgui/GCutAndPasteTransfer.java +++ b/src/jalview/jbgui/GCutAndPasteTransfer.java @@ -31,7 +31,7 @@ import java.awt.event.ActionListener; import java.awt.event.MouseEvent; import javax.swing.JButton; -import javax.swing.JInternalFrame; +import jalview.jbgui.ClassicJInternalFrame; import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JMenuItem; @@ -45,7 +45,7 @@ import javax.swing.JTextArea; * @author $author$ * @version $Revision$ */ -public class GCutAndPasteTransfer extends JInternalFrame +public class GCutAndPasteTransfer extends ClassicJInternalFrame { protected JTextArea textarea = new JTextArea(); diff --git a/src/jalview/jbgui/GPCAPanel.java b/src/jalview/jbgui/GPCAPanel.java index a6498d2..0fd7765 100755 --- a/src/jalview/jbgui/GPCAPanel.java +++ b/src/jalview/jbgui/GPCAPanel.java @@ -34,7 +34,7 @@ import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JCheckBoxMenuItem; import javax.swing.JComboBox; -import javax.swing.JInternalFrame; +import jalview.jbgui.ClassicJInternalFrame; import javax.swing.JLabel; import javax.swing.JMenu; import javax.swing.JMenuBar; @@ -43,7 +43,7 @@ import javax.swing.JPanel; import javax.swing.event.MenuEvent; import javax.swing.event.MenuListener; -public class GPCAPanel extends JInternalFrame +public class GPCAPanel extends ClassicJInternalFrame { private static final Font VERDANA_12 = new Font("Verdana", 0, 12); diff --git a/src/jalview/jbgui/GRnaStructureViewer.java b/src/jalview/jbgui/GRnaStructureViewer.java index 5dc726f..bcf2f47 100644 --- a/src/jalview/jbgui/GRnaStructureViewer.java +++ b/src/jalview/jbgui/GRnaStructureViewer.java @@ -20,10 +20,10 @@ */ package jalview.jbgui; -import javax.swing.JInternalFrame; +import jalview.jbgui.ClassicJInternalFrame; @SuppressWarnings("serial") -public class GRnaStructureViewer extends JInternalFrame +public class GRnaStructureViewer extends ClassicJInternalFrame { public GRnaStructureViewer() { diff --git a/src/jalview/jbgui/GSplitFrame.java b/src/jalview/jbgui/GSplitFrame.java index 5e65047..32ca61f 100644 --- a/src/jalview/jbgui/GSplitFrame.java +++ b/src/jalview/jbgui/GSplitFrame.java @@ -27,11 +27,11 @@ import java.awt.MouseInfo; import java.awt.Point; import java.awt.Rectangle; -import javax.swing.JInternalFrame; +import jalview.jbgui.ClassicJInternalFrame; import javax.swing.JSplitPane; import javax.swing.plaf.basic.BasicInternalFrameUI; -public class GSplitFrame extends JInternalFrame +public class GSplitFrame extends ClassicJInternalFrame { protected static final int DIVIDER_SIZE = 5; @@ -106,9 +106,9 @@ public class GSplitFrame extends JInternalFrame if (Platform.isAMacAndNotJS()) { // this saves some space - but doesn't hide the title bar - topFrame.putClientProperty("JInternalFrame.isPalette", true); + topFrame.putClientProperty("ClassicJInternalFrame.isPalette", true); // topFrame.getRootPane().putClientProperty("Window.style", "small"); - bottomFrame.putClientProperty("JInternalFrame.isPalette", true); + bottomFrame.putClientProperty("ClassicJInternalFrame.isPalette", true); } else { diff --git a/src/jalview/jbgui/GStructureChooser.java b/src/jalview/jbgui/GStructureChooser.java index 10e000f..326b0aa 100644 --- a/src/jalview/jbgui/GStructureChooser.java +++ b/src/jalview/jbgui/GStructureChooser.java @@ -57,7 +57,7 @@ import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JComboBox; import javax.swing.JFrame; -import javax.swing.JInternalFrame; +import jalview.jbgui.ClassicJInternalFrame; import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JPanel; @@ -108,7 +108,7 @@ public abstract class GStructureChooser extends JPanel protected String frameTitle = MessageManager .getString("label.structure_chooser"); - protected JInternalFrame mainFrame = new JInternalFrame(frameTitle); + protected ClassicJInternalFrame mainFrame = new ClassicJInternalFrame(frameTitle); protected JComboBox cmb_filterOption = new JComboBox<>(); diff --git a/src/jalview/jbgui/GStructureViewer.java b/src/jalview/jbgui/GStructureViewer.java index 4e13032..16e8c06 100644 --- a/src/jalview/jbgui/GStructureViewer.java +++ b/src/jalview/jbgui/GStructureViewer.java @@ -25,7 +25,7 @@ import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import javax.swing.JInternalFrame; +import jalview.jbgui.ClassicJInternalFrame; import javax.swing.JLabel; import javax.swing.JMenu; import javax.swing.JMenuBar; @@ -39,7 +39,7 @@ import jalview.util.ImageMaker.TYPE; import jalview.util.MessageManager; @SuppressWarnings("serial") -public abstract class GStructureViewer extends JInternalFrame +public abstract class GStructureViewer extends ClassicJInternalFrame implements JalviewStructureDisplayI, ColourChangeListener { // private AAStructureBindingModel bindingModel; diff --git a/src/jalview/jbgui/GTreePanel.java b/src/jalview/jbgui/GTreePanel.java index d184e76..dc617a3 100755 --- a/src/jalview/jbgui/GTreePanel.java +++ b/src/jalview/jbgui/GTreePanel.java @@ -29,7 +29,7 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JCheckBoxMenuItem; -import javax.swing.JInternalFrame; +import jalview.jbgui.ClassicJInternalFrame; import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JMenuItem; @@ -38,7 +38,7 @@ import javax.swing.event.MenuEvent; import javax.swing.event.MenuListener; @SuppressWarnings("serial") -public class GTreePanel extends JInternalFrame +public class GTreePanel extends ClassicJInternalFrame { BorderLayout borderLayout1 = new BorderLayout(); diff --git a/src/jalview/project/Jalview2XML.java b/src/jalview/project/Jalview2XML.java index d4b2c04..7bafe12 100644 --- a/src/jalview/project/Jalview2XML.java +++ b/src/jalview/project/Jalview2XML.java @@ -63,7 +63,7 @@ import java.util.jar.JarEntry; import java.util.jar.JarInputStream; import java.util.jar.JarOutputStream; -import javax.swing.JInternalFrame; +import jalview.jbgui.ClassicJInternalFrame; import javax.swing.SwingUtilities; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBElement; @@ -1083,7 +1083,7 @@ public class Jalview2XML * only view *should* be coped with sensibly. */ // This must have been loaded, is it still visible? - JInternalFrame[] frames = Desktop.desktop.getAllFrames(); + ClassicJInternalFrame[] frames = Desktop.desktop.getAllFrames(); String matchedFile = null; for (int f = frames.length - 1; f > -1; f--) { @@ -1239,7 +1239,7 @@ public class Jalview2XML // NOT IMPLEMENTED FOR HEADLESS STATE AT PRESENT if (Desktop.desktop != null) { - JInternalFrame[] frames = Desktop.desktop.getAllFrames(); + ClassicJInternalFrame[] frames = Desktop.desktop.getAllFrames(); for (int t = 0; t < frames.length; t++) { @@ -1285,7 +1285,7 @@ public class Jalview2XML */ if (!storeDS && Desktop.desktop != null) { - for (JInternalFrame frame : Desktop.desktop.getAllFrames()) + for (ClassicJInternalFrame frame : Desktop.desktop.getAllFrames()) { if (frame instanceof PCAPanel) { @@ -1931,7 +1931,7 @@ public class Jalview2XML { return; } - JInternalFrame[] frames = Desktop.desktop.getAllFrames(); + ClassicJInternalFrame[] frames = Desktop.desktop.getAllFrames(); for (int f = frames.length - 1; f > -1; f--) { if (frames[f] instanceof AppVarna) @@ -4132,7 +4132,7 @@ public class Jalview2XML * if load is repeated */ String postLoadId = viewer.getViewId() + viewIdSuffix; - for (JInternalFrame frame : getAllFrames()) + for (ClassicJInternalFrame frame : getAllFrames()) { if (frame instanceof AppVarna) { @@ -4456,8 +4456,8 @@ public class Jalview2XML final String sviewid = viewerData.getKey(); final StructureViewerModel svattrib = viewerData.getValue(); StructureViewerBase comp = null; - JInternalFrame[] frames = getAllFrames(); - for (JInternalFrame frame : frames) + ClassicJInternalFrame[] frames = getAllFrames(); + for (ClassicJInternalFrame frame : frames) { if (frame instanceof StructureViewerBase) { @@ -4547,9 +4547,9 @@ public class Jalview2XML * * @return */ - protected JInternalFrame[] getAllFrames() + protected ClassicJInternalFrame[] getAllFrames() { - JInternalFrame[] frames = null; + ClassicJInternalFrame[] frames = null; // TODO is this necessary - is it safe - risk of hanging? do { diff --git a/src/jalview/ws/jws2/MsaWSThread.java b/src/jalview/ws/jws2/MsaWSThread.java index ee0fbc5..f7a2e7d 100644 --- a/src/jalview/ws/jws2/MsaWSThread.java +++ b/src/jalview/ws/jws2/MsaWSThread.java @@ -46,7 +46,7 @@ import java.util.List; import java.util.Map; import java.util.Vector; -import javax.swing.JInternalFrame; +import jalview.jbgui.ClassicJInternalFrame; import compbio.data.msa.MsaWS; import compbio.metadata.Argument; @@ -1045,7 +1045,7 @@ class MsaWSThread extends AWS2Thread implements WSClientI af2.setTitle(complementTitle); String linkedTitle = MessageManager .getString("label.linked_view_title"); - JInternalFrame splitFrame = new SplitFrame( + ClassicJInternalFrame splitFrame = new SplitFrame( al.isNucleotide() ? af : af2, al.isNucleotide() ? af2 : af); Desktop.addInternalFrame(splitFrame, linkedTitle, -1, -1); return;