Full-screen can be somewhat problematic on different platforms, so the implementation of full-screen is left to a strategy implementation that you can choose or implement yourself.
As it happens, Windows is the most problematic platform for full-screen.
With vlcj 3.0.0+ there is a new full-screen strategy implementation that uses the Win32 native API. This is the most reliable and therefore recommended way to achieve full-screen on Windows.
You choose the strategy implementation when you create your media player:
EmbeddedMediaPlayer mediaPlayer =
mediaPlayerFactory.newEmbeddedMediaPlayer(new Win32FullScreenStrategy(frame));
Later when you want to toggle full-screen:
mediaPlayer.toggleFullScreen();
Or:
mediaPlayer.setFullScreen(boolean fullScreen);
If you want to listen to mouse-clicks, then in principle all you do is add a MouseListener
as you would usually do to your Canvas
object.
However, with Windows it's not so simple to detect mouse-clicks, you must do this when you create your media player:
mediaPlayer.setEnableMouseInputHandling(false);
mediaPlayer.setEnableKeyInputHandling(false);
Then in your MouseListener
implementation you can invoke one of the full-screen methods described above.
Note also that you must prevent your mediaPlayer
reference from being garbage collected. Usually it is enough to declare it as a class field rather than a heap variable (as you have in your posted code).
You should also look here for examples:
https://github.com/caprica/vlcj/blob/vlcj-3.0.1/src/test/java/uk/co/caprica/vlcj/test/fullscreen