I can creat a GUI in javafx and call the JMF component within JavaFx, just like this
public class JMFComponent extends SwingComponent{
var panel: JPanel;
public var center: java.awt.Component on replace{
println("[center] set component: {center}");
panel.add(center, BorderLayout.CENTER);
}
public override function createJComponent():javax.swing.JComponent{
panel= new JPanel(new BorderLayout());
var size:Dimension = new Dimension(width, height);
panel.setPreferredSize(size);
panel.setMinimumSize(size);
panel.setMaximumSize(size);
panel.setSize(size);
return panel;
}
}
public class MyMedia extends CustomNode {
var xpos: Number;
var ypos: Number;
var dx: Number;
public var url: java.net.URL;
public var autoPlay: Boolean;
public override function create(): Node{
var comp:java.awt.Component;
var control:java.awt.Component;
var w:Number;
var h:Number;
var cw:Number;
var ch:Number;
var jmfCom:JMFComponent;
var player = Manager.createRealizedPlayer(url);
comp=player.getVisualComponent();
control=player.getControlPanelComponent();
if (autoPlay) {
player.start();
}
w=comp.getPreferredSize().getWidth();
h=comp.getPreferredSize().getHeight();
cw=control.getPreferredSize().getWidth();
ch=control.getPreferredSize().getHeight();
jmfCom=JMFComponent {
width:w
height:h+ch
center: comp
blocksMouse: true
bottom: control
};
return Group{
content: [
jmfCom
]
}
}
}
Stage {
title: "Media Example"
width: 500
height: 500
onClose: function(){ java.lang.System.exit(0);}
scene: Scene {
content: MyMedia{
url: (
new java.io.File("C://My//Videos//DELTA.MPG")).toURI().toURL()
autoPlay: true
}
}
}
The video can be played within JavaFx gui, but when i move my mouse cursor into the control bar of the JMF player, the video window will move at the same time.
Does anyone have an idea how I can get JMF working normally within JavaFx?