4

I'm developing a JavaFX application which works perfectly fine on any Windows computer. Now I am trying to transfer that onto the Raspbian OS. My initial thought of perfect platform-independent Java got crashed really fast since I was not able to start the application without any configuration other than installing Raspbian, so I began reading into OpenJFX. After downloading and configuring OpenJFX (as explained in the Gluon Docs), I was able to start the application via sudo java -jar foo.jar. Fullscreen is fine and even the touch events of my RasPi-Display work when using sudo. The application contains a Button which executes the following:

FileChooser fileChooser = new FileChooser();
Window owner = null;
try {
  owner = gui.getScene().getWindow();
} catch (NullPointerException ignored) {}
if (...) {
  File initDirectory = ...
  if (initDirectory.exists()) {
    fileChooser.setInitialDirectory(initDirectory);
  }
}
File file = fileChooser.showOpenDialog(owner);
if (file != null) {
  ...
}

Dont worry about the ... parts, I removed them for the sake of easier code. Clicking this button produces the following error:

Exception in thread "JavaFX Application Thread" java.lang.UnsupportedOperationException
    at com.sun.glass.ui.monocle.MonocleApplication.staticCommonDialogs_showFileChooser(MonocleApplication.java:295)
    at com.sun.glass.ui.CommonDialogs.showFileChooser(CommonDialogs.java:212)
    at com.sun.javafx.tk.quantum.QuantumToolkit.showFileChooser(QuantumToolkit.java:1511)
    at javafx.stage.FileChooser.showDialog(FileChooser.java:416)
    at javafx.stage.FileChooser.showOpenDialog(FileChooser.java:350)
    at myclass [code shown above]
    at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
    at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
    at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)
    at javafx.event.Event.fireEvent(Event.java:198)
    at javafx.scene.Node.fireEvent(Node.java:8411)
    at javafx.scene.control.Button.fire(Button.java:185)
    at com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:182)
    at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:96)
    at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:89)
    at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218)
    at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
    at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
    at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
    at javafx.event.Event.fireEvent(Event.java:198)
    at javafx.scene.Scene$MouseHandler.process(Scene.java:3761)
    at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3489)
    at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1762)
    at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2498)
    at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:352)
    at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:275)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$353(GlassViewEventHandler.java:388)
    at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:391)
    at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:387)
    at com.sun.glass.ui.View.handleMouseEvent(View.java:555)
    at com.sun.glass.ui.View.notifyMouse(View.java:937)
    at com.sun.glass.ui.monocle.MonocleView.notifyMouse(MonocleView.java:119)
    at com.sun.glass.ui.monocle.MouseInput.notifyMouse(MouseInput.java:314)
    at com.sun.glass.ui.monocle.MouseInput.lambda$postMouseEvent$101(MouseInput.java:227)
    at com.sun.glass.ui.monocle.RunnableProcessor.runLoop(RunnableProcessor.java:93)
    at com.sun.glass.ui.monocle.RunnableProcessor.run(RunnableProcessor.java:52)
    at java.lang.Thread.run(Thread.java:748)

java -version shows the usual, 1.8.0_131-b11, and from this point I have no idea what to do here. Is showOpenDialog just not supported in OpenJFX and if so, can I find the documentation for that somewhere? Or is there some configuration missing on my side? Should I try a different OpenJFX distribution, maybe the ones by https://chriswhocodes.com/?

Thanks for any tip, hint or solution you can provide.

Sebu
  • 161
  • 4

1 Answers1

2

Alright, I continued to research about this and found that OpenJFX just not supports a FileChooser because Monocle, which is described as the implementation of the Glass windowing component of JavaFX for embedded systems in the OpenJFX Wiki, always throws an UnsupportedOperationException when a FileChooser should be shown (Source: OpenJFX repo, at line 287):

@Override
protected FileChooserResult staticCommonDialogs_showFileChooser(
        Window owner, String folder, String filename, String title,
        int type, boolean multipleMode,
        ExtensionFilter[] extensionFilters,
        int defaultFilterIndex) {
    throw new UnsupportedOperationException();
}

In my eyes this is really sad, because I need my application to run on an Raspberry Pi. This means, I have to delete funcionality from my application in order to let it run on Raspberry Pi. Very sad.

Sebu
  • 161
  • 4