We are about to switch to a new forum software. Until then we have removed the registration on this forum.
How to show a javafx Stage with the run method of a class implementing Tool ?
In Processing 3.01 I try :
public void run() {
Stage stage = new Stage();
Parent root = null;
try {
root = FXMLLoader.load(getClass().getResource("Doc.fxml"));
} catch (IOException ex) {
Logger.getLogger(MyTool.class.getName()).log(Level.SEVERE, null, ex);
}
Scene scene = new Scene(root);
stage.initModality(Modality.APPLICATION_MODAL);
stage.scene(transparentScene);
stage.setTitle("My tool");
stage.showAndWait();
When I click on MyTool menu line in Tool menu I get on the console :
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: Could not initialize class javafx.stage.Screen at javafx.stage.Window.(Window.java:1179) at javafx.stage.Stage.(Stage.java:236) at javafx.stage.Stage.(Stage.java:224) at tool.MunsellTool.run(Unknown Source) at processing.app.contrib.ToolContribution.run(ToolContribution.java:124) at processing.app.Base$5.actionPerformed(Base.java:746) at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022) at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2346) at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402) at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259) at javax.swing.AbstractButton.doClick(AbstractButton.java:376) at com.apple.laf.ScreenMenuItem.actionPerformed(ScreenMenuItem.java:125) at java.awt.MenuItem.processActionEvent(MenuItem.java:669) at java.awt.MenuItem.processEvent(MenuItem.java:628) at java.awt.MenuComponent.dispatchEventImpl(MenuComponent.java:351) at java.awt.MenuComponent.dispatchEvent(MenuComponent.java:339) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:761) at java.awt.EventQueue.access$500(EventQueue.java:97) at java.awt.EventQueue$3.run(EventQueue.java:709) at java.awt.EventQueue$3.run(EventQueue.java:703) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75) at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:86) at java.awt.EventQueue$4.run(EventQueue.java:731) at java.awt.EventQueue$4.run(EventQueue.java:729) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75) at java.awt.EventQueue.dispatchEvent(EventQueue.java:728) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93) at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
I miss something ?
Rievilo
Answers
Hello,
For people than may be interrested one solution is to use a jfxpanel as explained in :
https://docs.oracle.com/javafx/2/swing/swing-fx-interoperability.htm
This is certainly not the most elegant solution but it works ;-)