在javafx中的动画菜单栏

时间:2015-07-31 14:24:04

标签: java javafx menubar

是否有人在javafx中创建动画菜单栏。当鼠标移到顶部时,我需要显示菜单栏,当鼠标离开此区域时(25px在顶部),我需要隐藏。目前我有一些溶剂,但它看起来不像我想要的那样,只是显示/隐藏而没有任何滑动)))

root.setOnMouseMoved(new EventHandler<MouseEvent>() {
        @Override
        public void handle(MouseEvent event) {
            if (event.getY() < 25){
                menuBar.setVisible(true);
                root.setTopAnchor(clipPane, 35.0); 
            } else {
                if (menuBar.isVisible()) {
                    menuBar.setVisible(false);
                }

                if (menuFile.isShowing()) {
                    try {
                        Robot bot = new Robot();
                        bot.mousePress(InputEvent.BUTTON1_MASK);
                        bot.mouseRelease(InputEvent.BUTTON1_MASK);
                    } catch (AWTException ex) {
                    }
                }

                root.setTopAnchor(clipPane, 0.0);
            }
        }
    });

有人可以帮助提供有关如何为show / hide菜单栏添加滑动效果的信息吗?

1 个答案:

答案 0 :(得分:3)

经过几个小时的搜索,通过ParallelTransitions实现了它))

sprite1.position.set( event.clientX *(-.4) , event.clientY *(.4) , 1 );
mouse.x = ( event.clientX / window.innerWidth ) * 2 - 1;
mouse.y = - ( event.clientY / window.innerHeight ) * 2 + 1; 
相关问题