SwingTools.java 文件源码

java
阅读 25 收藏 0 点赞 0 评论 0

项目:SweetHome3D 作者:
/**
 * Returns a scroll bar adjustment listener bound to the given <code>scrollPane</code> view
 * that updates view tool tip when its vertical scroll bar is adjusted.
 */
public static AdjustmentListener createAdjustmentListenerUpdatingScrollPaneViewToolTip(final JScrollPane scrollPane)
{
    return new AdjustmentListener()
    {
        public void adjustmentValueChanged(AdjustmentEvent ev)
        {
            Point screenLocation = MouseInfo.getPointerInfo().getLocation();
            Point point = new Point(screenLocation);
            Component view = scrollPane.getViewport().getView();
            SwingUtilities.convertPointFromScreen(point, view);
            if (scrollPane.isShowing() && scrollPane.getViewport().getViewRect().contains(point))
            {
                MouseEvent mouseEvent = new MouseEvent(view, MouseEvent.MOUSE_MOVED, System.currentTimeMillis(), 0,
                        point.x, point.y, 0, false, MouseEvent.NOBUTTON);
                if (isToolTipShowing())
                {
                    ToolTipManager.sharedInstance().mouseMoved(mouseEvent);
                }
            }
        }
    };
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号