3 import jalview.util.Platform;
5 import java.awt.Component;
6 import java.awt.MouseInfo;
8 import java.awt.Rectangle;
10 import javax.swing.JInternalFrame;
11 import javax.swing.JSplitPane;
12 import javax.swing.plaf.basic.BasicInternalFrameUI;
14 public class GSplitFrame extends JInternalFrame
16 private static final long serialVersionUID = 1L;
18 private GAlignFrame topFrame;
20 private GAlignFrame bottomFrame;
22 private JSplitPane splitPane;
30 public GSplitFrame(GAlignFrame top, GAlignFrame bottom)
33 this.bottomFrame = bottom;
41 * Create and add the split pane containing the top and bottom components.
43 protected void addSplitPane()
45 splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, topFrame,
47 splitPane.setVisible(true);
48 splitPane.setDividerLocation(0.5d);
49 splitPane.setResizeWeight(0.5d);
50 splitPane.setDividerSize(0);
55 * Try to hide the title bars as a waste of precious space.
58 * ://stackoverflow.com/questions/7218971/java-method-works-on-windows
59 * -but-not-macintosh -java
61 protected void hideTitleBars()
63 if (new Platform().isAMac())
65 // this saves some space - but doesn't hide the title bar
66 topFrame.putClientProperty("JInternalFrame.isPalette", true);
67 // topFrame.getRootPane().putClientProperty("Window.style", "small");
68 bottomFrame.putClientProperty("JInternalFrame.isPalette", true);
72 ((BasicInternalFrameUI) topFrame.getUI()).setNorthPane(null);
73 ((BasicInternalFrameUI) bottomFrame.getUI()).setNorthPane(null);
77 public GAlignFrame getTopFrame()
82 public GAlignFrame getBottomFrame()
88 * Returns the split pane component the mouse is in, or null if neither.
92 protected GAlignFrame getFrameAtMouse()
94 Point loc = MouseInfo.getPointerInfo().getLocation();
96 if (isIn(loc, splitPane.getTopComponent()))
100 else if (isIn(loc, splitPane.getBottomComponent()))
102 return getBottomFrame();
107 private boolean isIn(Point loc, Component comp)
109 Point p = comp.getLocationOnScreen();
110 Rectangle r = new Rectangle(p.x, p.y, comp.getWidth(), comp.getHeight());
111 return r.contains(loc);