Search code examples
javaxuggler

Xuggler adding control to VideoImage window


I'm new to Xuggler and I'm using it to play some video in a Windows environment. I want the user to draw on the video where I take the drawings and then save them to a database. I have the video playing and I can draw on it, but I'm having a problem that I can't quite figure out how to attach controls to the VideoImage. The code I'm writing is below, and the problem is that whatever controls I add cover the whole screen. It's like the "setBounds" has no effect nor does the "setMaximumSize".

        private static VideoImage mScreen = null;

        LayoutManager lm = mScreen.getLayout();         
        Panel controlPanel = new Panel(lm);
        controlPanel.setBackground(Color.red);              
        controlPanel.setBounds(new Rectangle(10, 10, 10, 10));
        controlPanel.setMaximumSize(new Dimension(10, 10));

        mScreen.getContentPane().add(controlPanel); 

The final line, mScreen.getContentPane returns a JFrame. The VideoImage class also has an "add" function of its own that I used to attach the control. I get the same effect for both calls. My Panel is stretched across the whole screen and hides the video. I'm calling this code in both the video decoding loop where it sends the decoded image to the screen as well as when the windows was created. No luck either way.

My question is why would this behavior be happening? Does anyone know any idiosyncrasies of Xuggler or Java GUI components that could be causing this?

EDIT 0

I just discovered something. I set the layout manager to null in mScreen (VideoImage type) and my panel shows up correctly. The problem now appears that the video has disappeared. I think it's in the upper left side since I see a little sliver of what I think is the bottom of the video but I can't tell.

/EDIT 0

EDIT 1

I found another little tidbit. The LayoutManager in use is a BorderLayout. I can add things to the main content pane and specify what location should be in the BorderLayout. Below I add my panel to the SOUTH position. I have a red area added in the south position that is 10 px tall and spans the whole screen.

    Panel controlPanel = new Panel();
    controlPanel.setBackground(Color.red);              
    controlPanel.setBounds(new Rectangle(10, 10, 10, 10));
    controlPanel.setMaximumSize(new Dimension(10, 10));

    Container cont = mScreen.getContentPane();
    cont.add(controlPanel, BorderLayout.SOUTH);

/EDIT 1

EDIT 2

I figured it out. If I just leave the panel and start adding to it I can add the controls I want.

/EDIT2


Solution

  •     mScreen = new VideoImage();     
    
        Panel controlPanel = new Panel();               
        controlPanel.setBounds(new Rectangle(10, 10, 10, 10));
        controlPanel.setMaximumSize(new Dimension(10, 10));
        Container cont = mScreen.getContentPane();
        cont.add(controlPanel, BorderLayout.SOUTH);
    

    This is how I did it.