Details
Description
When a scene with a MenuBar is hosted in a JFXPanel the MenuItems do not change their appearance on mouseover and do not respond to mouse clicks.
This problem also affects ChoiceBox controls as well.
This problem only occurs on Linux. It does not occur on Windows 7.
This is a regression from 7u55. The problem does not occur on both Windows or Linux when using Java 7
The example below demonstrates the problem.
import java.awt.HeadlessException;
import javafx.application.Platform;
import javafx.embed.swing.JFXPanel;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuBar;
import javafx.scene.control.MenuItem;
import javafx.scene.layout.BorderPane;
import javax.swing.JFrame;
public class JFxPanelMenuTest extends JFrame {
public JFxPanelMenuTest() throws HeadlessException {
super("FX Menu Test JFXPanel");
setSize(200, 200);
final JFXPanel fxPanel = new JFXPanel();
add(fxPanel);
Platform.runLater(new Runnable() {
@Override
public void run() {
fxPanel.setScene(buildScene());
}
});
}
private Scene buildScene() {
BorderPane fxContent = new BorderPane();
MenuBar menus = new MenuBar();
Menu menu = new Menu("First");
menu.getItems().addAll(createMenuItem("Item One"), createMenuItem("Item Two"), createMenuItem("Item Three"));
menus.getMenus().add(menu);
fxContent.topProperty().set(menus);
return new Scene(fxContent);
}
private MenuItem createMenuItem(final String name) {
MenuItem menuItem = new MenuItem(name);
menuItem.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent arg0) {
System.out.println("Mouse clicked " + name);
}
});
return menuItem;
}
public static void main(String[] args) {
JFxPanelMenuTest menuTest = new JFxPanelMenuTest();
menuTest.setDefaultCloseOperation(EXIT_ON_CLOSE);
menuTest.setVisible(true);
}
}
This problem also affects ChoiceBox controls as well.
This problem only occurs on Linux. It does not occur on Windows 7.
This is a regression from 7u55. The problem does not occur on both Windows or Linux when using Java 7
The example below demonstrates the problem.
import java.awt.HeadlessException;
import javafx.application.Platform;
import javafx.embed.swing.JFXPanel;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuBar;
import javafx.scene.control.MenuItem;
import javafx.scene.layout.BorderPane;
import javax.swing.JFrame;
public class JFxPanelMenuTest extends JFrame {
public JFxPanelMenuTest() throws HeadlessException {
super("FX Menu Test JFXPanel");
setSize(200, 200);
final JFXPanel fxPanel = new JFXPanel();
add(fxPanel);
Platform.runLater(new Runnable() {
@Override
public void run() {
fxPanel.setScene(buildScene());
}
});
}
private Scene buildScene() {
BorderPane fxContent = new BorderPane();
MenuBar menus = new MenuBar();
Menu menu = new Menu("First");
menu.getItems().addAll(createMenuItem("Item One"), createMenuItem("Item Two"), createMenuItem("Item Three"));
menus.getMenus().add(menu);
fxContent.topProperty().set(menus);
return new Scene(fxContent);
}
private MenuItem createMenuItem(final String name) {
MenuItem menuItem = new MenuItem(name);
menuItem.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent arg0) {
System.out.println("Mouse clicked " + name);
}
});
return menuItem;
}
public static void main(String[] args) {
JFxPanelMenuTest menuTest = new JFxPanelMenuTest();
menuTest.setDefaultCloseOperation(EXIT_ON_CLOSE);
menuTest.setVisible(true);
}
}
Attachments
Issue Links
- relates to
-
JDK-8094373 [SwingNode, Linux] : popup menu cannot get action events
- Closed