Would not EmbeddedMediaPlayerComponent support layouts other than BorderLayout.
Of course it would. Your constraints are probably wrong, but since you didn't post your code, it's impossible to say.
GridBag sucks. I always prefer nested BorderLayout, with BoxLayout as needed.
Anyway here's your two-minute example.
Code: Select all
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import uk.co.caprica.vlcj.component.EmbeddedMediaPlayerComponent;
public class GridBagTest {
private final JFrame f;
private final EmbeddedMediaPlayerComponent mediaPlayer;
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
new GridBagTest().start();
}
});
}
private GridBagTest() {
GridBagLayout gbl = new GridBagLayout();
JPanel cp = new JPanel();
cp.setLayout(gbl);
GridBagConstraints gbc;
gbc = new GridBagConstraints();
gbc.weightx = 1.0f;
gbc.weighty = 1.0f;
gbc.fill = GridBagConstraints.BOTH;
gbc.gridwidth = GridBagConstraints.REMAINDER;
gbc.anchor = GridBagConstraints.CENTER;
mediaPlayer = new EmbeddedMediaPlayerComponent();
cp.add(mediaPlayer, gbc);
gbc = new GridBagConstraints();
gbc.weightx = 1.0f;
gbc.weighty = 0.0f;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.gridwidth = GridBagConstraints.REMAINDER;
gbc.anchor = GridBagConstraints.CENTER;
JPanel someOtherPanel = new JPanel();
someOtherPanel.add(new JButton("Play"));
someOtherPanel.add(new JButton("Stop"));
someOtherPanel.add(new JButton("Pause"));
cp.add(someOtherPanel, gbc);
f = new JFrame("Test");
f.setContentPane(cp);
f.setSize(800, 600);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true);
}
private void start() {
mediaPlayer.getMediaPlayer().playMedia("your-movie.mpg");
}
}