视频播放器控制面板? JavaFX的

时间:2013-09-15 01:06:03

标签: javafx-2 media-player

我想在鼠标移动时消失视频播放器控制面板。我编写了以下用于检测鼠标移动的代码,但未在我的控制面板上应用。

gp.setOnMouseDragOver(new EventHandler<MouseDragEvent>() {
        @Override
        public void handle(MouseDragEvent mouseDragEvent) {
            FadeTransition f
                    = new FadeTransition(Duration.millis(5000),openButton );
            f.setFromValue(0.0);
            f.setFromValue(0);
            f.play();
            FadeTransition f1
                    = new FadeTransition(Duration.millis(5000),volLow );
            f1.setFromValue(0.0);
            f1.setFromValue(0);
            f1.play();
            FadeTransition f2
                    = new FadeTransition(Duration.millis(5000),volHigh );
            f2.setFromValue(0.0);
            f2.setFromValue(0);
            f2.play();
            FadeTransition f3
                    = new FadeTransition(Duration.millis(5000),volumeSlider );
            f3.setFromValue(0.0);
            f3.setFromValue(0);
            f3.play();
            FadeTransition f4
                    = new FadeTransition(Duration.millis(5000),controlPanel );
            f4.setFromValue(0.0);
            f4.setFromValue(0);
            f4.play();
            FadeTransition f5
                    = new FadeTransition(Duration.millis(5000),statusLabel );
            f5.setFromValue(0.0);
            f5.setFromValue(0);
            f5.play();
            FadeTransition f6
                    = new FadeTransition(Duration.millis(5000),currentTimeLabel );
            f6.setFromValue(0.0);
            f6.setFromValue(0);
            f6.play();
            FadeTransition f7
                    = new FadeTransition(Duration.millis(5000),positionSlider );
            f7.setFromValue(0.0);
            f7.setFromValue(0);
            f7.play();
            FadeTransition f8
                    = new FadeTransition(Duration.millis(5000),totalDurationLabel );
            f8.setFromValue(0.0);
            f8.setFromValue(0);
            f8.play();
            FadeTransition f9
                    = new FadeTransition(Duration.millis(5000),eqButton );
            f9.setFromValue(0.0);
            f9.setFromValue(0);
            f9.play();


        }
    });
    gp.setOnMouseMoved(new EventHandler<MouseEvent>() {
        @Override
        public void handle(MouseEvent mouseEvent) {
            FadeTransition f
                    = new FadeTransition(Duration.millis(3000),openButton);

            f.setFromValue(9.0);
            f.setToValue(0.0);
            f.play();
            FadeTransition f1
                    = new FadeTransition(Duration.millis(3000),volLow);

            f1.setFromValue(9.0);
            f1.setToValue(0.0);
            f1.play();
            FadeTransition f2
                    = new FadeTransition(Duration.millis(3000),volHigh);

            f2.setFromValue(9.0);
            f2.setToValue(0.0);
            f2.play();
            FadeTransition f3
                    = new FadeTransition(Duration.millis(3000),volumeSlider);

            f3.setFromValue(9.0);
            f3.setToValue(0.0);
            f3.play();
            FadeTransition f4
                    = new FadeTransition(Duration.millis(3000),controlPanel);

            f4.setFromValue(9.0);
            f4.setToValue(0.0);
            f4.play();
            FadeTransition f5
                    = new FadeTransition(Duration.millis(3000),statusLabel);

            f5.setFromValue(9.0);
            f5.setToValue(0.0);
            f5.play();
            FadeTransition f6
                    = new FadeTransition(Duration.millis(3000),currentTimeLabel);

            f6.setFromValue(9.0);
            f6.setToValue(0.0);
            f6.play();
            FadeTransition f7
                    = new FadeTransition(Duration.millis(3000),positionSlider);

            f7.setFromValue(9.0);
            f7.setToValue(0.0);
            f7.play();
            FadeTransition f8
                    = new FadeTransition(Duration.millis(3000),totalDurationLabel);

            f8.setFromValue(9.0);
            f8.setToValue(0.0);
            f8.play();
            FadeTransition f9
                    = new FadeTransition(Duration.millis(3000),eqButton);

            f9.setFromValue(9.0);
            f9.setToValue(0.0);
            f9.play();


        }
    });
return gp;

为了检测鼠标移动,我编写了以下代码,但是如何将两个代码一起应用。

public class Mouse {
public static void main(String[] args) throws InterruptedException{
        int posx1;
        int posx2;
        int posy1;
        int posy2;

        while(true){
        Thread.sleep(1);
        posx2=MouseInfo.getPointerInfo().getLocation().x;
        posy2=MouseInfo.getPointerInfo().getLocation().y;

    Thread.sleep(100);
        posx1=MouseInfo.getPointerInfo().getLocation().x;
        posy1=MouseInfo.getPointerInfo().getLocation().y;
                      if(posx1==posx2&&posy1==posy2){
                   System.out.println("mouse hareket etmedi");
                      }
        else{
            System.out.println("HAREKET VAR");
        }


                    }




       }                 
}       

0 个答案:

没有答案