简体   繁体   中英

MouseListener seems to doesn't work on EmbeddedMediaPlayerComponent

EmbeddedMediaPlayerComponent component = new EmbeddedMediaPlayerComponent();
component.setPreferredSize(new Dimension(537, 374));
panel.add(component, BorderLayout.WEST);

component.addMouseListener(new MouseAdapter() {
    public void mouseClicked (MouseEvent e) {
           if (e.getClickCount() == 2) {
            System.out.println("success");
           }
    }
});

I want to print message when I double click screen (EmbeddedMediaPlayerComponent) on JPanel I think this code has no error but it doesn't print "success" I hope you help me. Thank you.

Try to add the mouse listener to the video surface component:

mediaPlayerComponent.videoSurfaceComponent().addMouseListener(new MouseAdapter() {
    @Override
    public void mouseClicked(MouseEvent e) {
        System.out.println("click");
    }
});

In some older versions the method is called getVideoSurface() .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM