Playing a video from an array of vlcj player

大城市里の小女人 提交于 2019-12-02 08:37:51

The BorderLayout.CENTER of your JPanel video_pnl can only hold a single component. After your constructor's loop concludes, it references the last mediaplayer[i] added. In your listener, you can use CardLayout to change panels or update a single panel.

Your event handler has this:

if(e.getSource() == play_btn){

e.getSource() will return the button that was clicked. However, play_btn is an array not a button. You are therefore comparing an array instance and a button instance for equality and that will always be false.

One way to achieve what you want is to use action commands:

play_btn[i] = new JButton("play");
play_btn[i].setActionCommand("play");

You can then change the test in your event handler to this:

if(e.getActionCommand().equals("play") {

By the way, this problem is really nothing at all to do with vlcj.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!