Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9250729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:31:01+00:00 2026-06-18T10:31:01+00:00

I have created a simple VLCJ project that consists of a simple embedded player

  • 0

I have created a simple VLCJ project that consists of a simple embedded player and a button to exit.

The code is as follows:

package test;

import java.awt.BorderLayout;
import java.awt.Button;
import java.awt.Color;
import java.awt.Frame;
import java.awt.Panel;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;

import uk.co.caprica.vlcj.binding.LibVlc;
import uk.co.caprica.vlcj.component.EmbeddedMediaPlayerComponent;
import uk.co.caprica.vlcj.runtime.RuntimeUtil;

import com.sun.jna.Native;
import com.sun.jna.NativeLibrary;

public class Demo {


private final JFrame frame; 
private final EmbeddedMediaPlayerComponent mediaPlayerComponent;
private JPanel videoPane;
private JPanel buttonPane;
private Button exitButton;
private ActionListener a;

private static String vlc_location = "C:\\Program Files\\VideoLAN\\VLC";

public static void main(String[] args) {

    NativeLibrary.addSearchPath(RuntimeUtil.getLibVlcLibraryName(), vlc_location);
    Native.loadLibrary(RuntimeUtil.getLibVlcLibraryName(), LibVlc.class);

    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            new Demo().run();
        }
    });
}

public Demo() { 

    mediaPlayerComponent = new EmbeddedMediaPlayerComponent();

    a = new MyActionListener();
    exitButton = new Button("Exit");
    exitButton.setActionCommand("Exit app");        
    exitButton.addActionListener(a);

    buttonPane = new JPanel();
    buttonPane.setLayout(new BorderLayout());
    buttonPane.setBackground(Color.black);
    buttonPane.add(exitButton, BorderLayout.CENTER);

    videoPane = new JPanel();
    videoPane.setLayout(new BorderLayout());
    videoPane.setBackground(Color.black);
    videoPane.add(mediaPlayerComponent, BorderLayout.CENTER);
    videoPane.add(buttonPane, BorderLayout.PAGE_END);


    frame = new JFrame("vlcj demo");        
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setLocation(100, 100);
    frame.setSize(1200, 800);       
    frame.setContentPane(videoPane);        
    frame.setVisible(true);
}

public void run() {         
    mediaPlayerComponent.getMediaPlayer().playMedia(video_file);
}

class MyActionListener implements ActionListener {

    @Override
    public void actionPerformed(ActionEvent arg0) {
        String s = arg0.getActionCommand();

        if (s.equals("Exit")) {
            System.exit(0);
        }

    }

}

}

The problem is that the button does show up but it cannot be clicked. When i removed the videoPane, it was back to clickable! Any ideas if I’m missing something?

I am using the version 2.1.0 for vlcj.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T10:31:02+00:00Added an answer on June 18, 2026 at 10:31 am

    Thanks MadProgrammer for your advise. I went on to think about it and tried commenting away the line of code in run(). The JButton came back!

    However, when i un-commented the code in run(), the JButton disappeared. I was thinking maybe the Swing runnable was causing issue with the creation of the JButton.

    Hence, what i did was to comment away the whole Swing runnable and just use:

    final Demo demo = new Demo();
    demo.run();
    

    The demo can now play video and display the Exit button, thanks!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created the simple web service. Code: [ServiceContract] public interface ITsdxService { [OperationContract]
I have created a simple test form with FormBorderStyle = FixedToolWindow by default and
i have created a simple public ref class in the vc++ project, which is
I have created a simple WordPress plugin that automatically sets my new sites up
Have created simple Ajax enabled contact forms before that have around 12 fields -
I have created simple Java class to test file writes from applets: update appeared
I have created windows service project in vs2008. I have created simple serivce project
I have created a simple multicast player using actinscript 3 which works fine and
I have created a simple text input box that will be used to fetch
I have created simple Java Dynamic Web project in Eclipse. I host my project

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.