]> git.sesse.net Git - vlc/blob - bindings/java/org/videolan/jvlc/JVLCCanvas.java
Destroy the jvlc instance when the remove notify method is invoked (avoids some jvm...
[vlc] / bindings / java / org / videolan / jvlc / JVLCCanvas.java
1 /*****************************************************************************
2  * JVLCCanvas.java: AWT Canvas containing VLC Video Output
3  *****************************************************************************
4  * 
5  * Copyright (C) 1998-2006 the VideoLAN team
6  * 
7  * Author: Filippo Carone <filippo@carone.org>
8  *
9  * Created on 25-nov-2005
10  *
11  * $Id$
12  * 
13  * This program is free software; you can redistribute it
14  * and/or modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2 of the
16  * License, or (at your option) any later version.
17  * 
18  * This program is distributed in the hope that it will be useful, but
19  * WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
21  * General Public License for more details.
22  * 
23  * You should have received a copy of the GNU General Public
24  * License along with this program; if not, write to the Free Software
25  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
26  * 
27  */
28
29 package org.videolan.jvlc;
30
31 import java.awt.Canvas;
32 import java.awt.Graphics;
33
34 public class JVLCCanvas extends Canvas {
35
36         public void paint(Graphics g) {
37                 jvlc.video.paint(g);
38         }
39
40     private final JVLC jvlc;
41     
42     /**
43      * Default constructor. The canvas is set a dimension of 200x200
44      */
45     public JVLCCanvas() {
46         super();
47         jvlc = new JVLC();
48         jvlc.video.setActualCanvas(this);
49         setSize(200, 200);
50     }
51     
52     public JVLCCanvas(String[] args) {
53         super();
54         jvlc = new JVLC(args);
55         jvlc.video.setActualCanvas(this);
56         setSize(200, 200);
57     }
58     
59     /**
60      * @param width The initial canvas width
61      * @param height The initial canvas height
62      */
63     public JVLCCanvas(int width, int height) {
64         super();
65         jvlc = new JVLC();
66         jvlc.video.setActualCanvas(this);        
67         setSize(width, height);
68     }
69     
70     public JVLCCanvas(String[] args, int width, int height) {
71         super();
72         jvlc = new JVLC(args);
73         jvlc.video.setActualCanvas(this);        
74         setSize(width, height);
75     }
76
77     public JVLCCanvas(JVLC jvlc) {
78         super();
79         this.jvlc = jvlc;
80         jvlc.video.setActualCanvas(this);        
81     }
82     
83     public JVLC getJVLC() {
84         return jvlc;
85     }
86     
87     /* (non-Javadoc)
88      * @see java.awt.Component#removeNotify()
89      */
90     public void removeNotify() {
91         super.removeNotify();
92         jvlc.destroy();
93     }
94
95 }