|
|
|
@ -10,6 +10,7 @@ import com.fr.stable.Constants;
|
|
|
|
|
|
|
|
|
|
import javax.swing.AbstractButton; |
|
|
|
|
import javax.swing.JPanel; |
|
|
|
|
import javax.swing.JWindow; |
|
|
|
|
import javax.swing.border.AbstractBorder; |
|
|
|
|
import javax.swing.event.AncestorEvent; |
|
|
|
|
import javax.swing.event.AncestorListener; |
|
|
|
@ -20,6 +21,7 @@ import java.awt.Dimension;
|
|
|
|
|
import java.awt.Graphics; |
|
|
|
|
import java.awt.Graphics2D; |
|
|
|
|
import java.awt.Insets; |
|
|
|
|
import java.awt.Point; |
|
|
|
|
import java.awt.Rectangle; |
|
|
|
|
import java.awt.RenderingHints; |
|
|
|
|
import java.awt.event.MouseAdapter; |
|
|
|
@ -99,9 +101,25 @@ public abstract class AbstractSelectBox<T> extends AbstractPopBox implements Mou
|
|
|
|
|
displayComponent.addMouseListener(new MouseAdapter() { |
|
|
|
|
@Override |
|
|
|
|
public void mouseExited(MouseEvent e) { |
|
|
|
|
if (!isPopupVisible()) { |
|
|
|
|
//如果弹出框==null 或者 弹出框不可见 直接return
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
Point popMenuP = getControlWindow().getLocation(); |
|
|
|
|
Point displayComponentP = displayComponent.getLocationOnScreen(); |
|
|
|
|
if (popMenuP.getX() < displayComponentP.getX() - 1) { |
|
|
|
|
//如果 弹出框横向超出屏幕 往左调整了 和displayComponent横向错开 就不处理了
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Rectangle rectangle = displayComponent.getBounds(); |
|
|
|
|
if (e.getY() < rectangle.y) { |
|
|
|
|
//如果是从displayComponent上面离开的,隐藏弹出界面。
|
|
|
|
|
boolean bottomPopAndExitTop = displayComponentP.getY() < popMenuP.getY() && e.getY() <= rectangle.y; |
|
|
|
|
boolean topPopAndExitBottom = displayComponentP.getY() > popMenuP.getY() && e.getY() >= rectangle.y + rectangle.getHeight(); |
|
|
|
|
boolean exitLeftOrRight = rectangle.x > e.getX() || rectangle.x + rectangle.getWidth() < e.getX(); |
|
|
|
|
if (bottomPopAndExitTop || topPopAndExitBottom || exitLeftOrRight) { |
|
|
|
|
//弹出框在displayComponent下面 且 鼠标是从displayComponent上面离开的,隐藏弹出界面。
|
|
|
|
|
//弹出框在displayComponent上面 且 鼠标是从displayComponent下面离开的,隐藏弹出界面。
|
|
|
|
|
//鼠标从displayComponent左边 或者 右边 离开,隐藏弹出界面。
|
|
|
|
|
hidePopupMenu(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|