1. Compile and embed the attached sample applet containing an embedded JavaFx Menu in an HTML file
2. Open a browser (Firefox was used to demonstrate this issue) and maximize it. Navigate to the HTML file containing the embedded applet.
3. Double click on the browser title bar to reduce it's size
4. Click on the Menu in the menu bar. Observe that the drop down will appear completely outside the bounds of the browser window in a location that would have been valid for the maximized window
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
public class FxApplet extends JApplet
{
protected Scene scene;
protected Group root;
@Override
public final void init() { // This method is invoked when applet is loaded
SwingUtilities.invokeLater(new Runnable()
{
@Override
public void run()
{
initSwing();
}
});
}
private void initSwing() { // This method is invoked on Swing thread
final JFXPanel fxPanel = new JFXPanel();
add(fxPanel);
Platform.runLater(new Runnable()
{
@Override
public void run()
{
initFX(fxPanel);
initApplet();
}
});
}
private void initFX(JFXPanel fxPanel) { // This method is invoked on JavaFX thread
root = new Group();
scene = new Scene(root);
fxPanel.setScene(scene);
}
public void initApplet() {
MenuBar menuBar = new MenuBar();
Menu menuFile = new Menu("Menu");
menuFile.getItems().addAll(new MenuItem("item 1"),
new MenuItem("item 2"),
new MenuItem("item 3"),
new MenuItem("item 4"));
menuBar.getMenus().addAll(menuFile);
root.getChildren().addAll(menuBar);
}
}
2. Open a browser (Firefox was used to demonstrate this issue) and maximize it. Navigate to the HTML file containing the embedded applet.
3. Double click on the browser title bar to reduce it's size
4. Click on the Menu in the menu bar. Observe that the drop down will appear completely outside the bounds of the browser window in a location that would have been valid for the maximized window
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
public class FxApplet extends JApplet
{
protected Scene scene;
protected Group root;
@Override
public final void init() { // This method is invoked when applet is loaded
SwingUtilities.invokeLater(new Runnable()
{
@Override
public void run()
{
initSwing();
}
});
}
private void initSwing() { // This method is invoked on Swing thread
final JFXPanel fxPanel = new JFXPanel();
add(fxPanel);
Platform.runLater(new Runnable()
{
@Override
public void run()
{
initFX(fxPanel);
initApplet();
}
});
}
private void initFX(JFXPanel fxPanel) { // This method is invoked on JavaFX thread
root = new Group();
scene = new Scene(root);
fxPanel.setScene(scene);
}
public void initApplet() {
MenuBar menuBar = new MenuBar();
Menu menuFile = new Menu("Menu");
menuFile.getItems().addAll(new MenuItem("item 1"),
new MenuItem("item 2"),
new MenuItem("item 3"),
new MenuItem("item 4"));
menuBar.getMenus().addAll(menuFile);
root.getChildren().addAll(menuBar);
}
}