views:

211

answers:

1

Hello,

I've got a problem: I have a JMF-Videoplayer in my application and I want to draw on it (while the video continues). The Problem I've got is that I use a JLayeredPane where I add the VideoPlayer-Control on Layer.Content_Layer(index 0) and a JPanel (setOpaque(false)) on Layer.Modal_Layer(index 300).

What happens is, when I add the JPanel it is not opaque but I see the drawn lines but not the video. If I add the JPanel before (didn't changed the index of the layer) I add the video-control then I see the video but not the drawn lines.

Has someone an idea why this doesn't work and how I could make it work?

I thought about adding an ActionListener to the video-control-component and evertime the image changes, I take this image and paint it as background on the JPanel but I'm affraid that this will cost me precious time.

My code looks like this:

        Manager.setHint( Manager.LIGHTWEIGHT_RENDERER, true );
        mediaPlayer = Manager.createRealizedPlayer(url);

        this.videoPane = new JLayeredPane();
        this.videoPane.setLayout(new BorderLayout());            

        // get the components for the video and the playback controls
        this.video = mediaPlayer.getVisualComponent();
        this.controls = mediaPlayer.getControlPanelComponent();

        this.drawPanel = new JLabel();
        this.drawPanel.setSize(video.getWidth(), video.getHeight());
        this.drawPanel.setOpaque(false);

        if ( video != null )
           this.videoPane.add(video, BorderLayout.CENTER, JLayeredPane.FRAME_CONTENT_LAYER);

        if ( controls != null )
           this.videoPlayerPanel.add( controls, BorderLayout.SOUTH);

        this.videoPane.add(drawPanel, BorderLayout.CENTER, JLayeredPane.MODAL_LAYER);
        this.videoPlayerPanel.add(videoPane, BorderLayout.CENTER);

The videoPlayerPanel is also a JPanel that contains the JLayeredPane... as you can see.

Edit: Okay I put some research into it and found out that

mediaPlayer.getVisualComponent();

returns a java.awt.Component and such components do not support opacity - maybe that's the reason why I cannot see or only see the drawPanel.

So currently I'm trying to draw directly onto the video-Component by adding it to a customized Panel where i override the paint-method to draw all the lines. Any other ideas?

A: 

answered by the answer to this question.

using 2 JInternalFrames where the lightweight-component is on one frame and the heavyweight-jpanel on the other.

Gambrinus