Example usage for java.awt Canvas setSize

List of usage examples for java.awt Canvas setSize

Introduction

In this page you can find the example usage for java.awt Canvas setSize.

Prototype

public void setSize(Dimension d) 

Source Link

Document

Resizes this component so that it has width d.width and height d.height .

Usage

From source file:biometricgui.MainWindow.java

void runMedia(String filePath) {
    NativeDiscovery nd = new NativeDiscovery();
    if (!nd.discover()) {
        System.out.println("VLC not found");
        System.exit(-1);// www . j a v a 2s  .  co  m
    }
    Canvas canvas = new Canvas();
    jPanel1.add(canvas);
    canvas.setSize(jPanel1.getSize());
    jPanel1.revalidate();
    jPanel1.repaint();

    MediaPlayerFactory mediaPlayerFactory = new MediaPlayerFactory();
    EmbeddedMediaPlayer mediaPlayer = mediaPlayerFactory.newEmbeddedMediaPlayer();
    CanvasVideoSurface videoSurface = mediaPlayerFactory.newVideoSurface(canvas);
    mediaPlayer.setVideoSurface(videoSurface);
    jLabel2.setVisible(false);
    mediaPlayer.playMedia(filePath);
}