6

I need some functionality that I cannot find currently in JavaFX. Like the Robot or the Tray Icon.

I know these tools do work with JavaFx applications. But is it ok to use them? Are there any considerations that I should care of?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
betaman
  • 1,865
  • 5
  • 25
  • 30
  • I'm not an JavaFx expert, but for me it seem to be a very solid solution. Can't complain... Please not that I'm programming on a win-system for win-systems. – Martin Pfeffer Sep 17 '15 at 23:06

1 Answers1

6

Generally it's not advised.

N.B.:

  • using any AWT from JavaFX will start whole AWT stack which can increase memory/proc consumption.
  • there could be threading conflicts between Glass (FX UI stack) and AWT, especially on Mac. So it maybe worth using Swing Interoperability approach for your app as JFXPanel is aware how to handle that conflicts.
  • you can use Glass robot instead of AWT one (although it's not public API and may be changed in future):

    Robot robot = com.sun.glass.ui.Application.GetApplication().createRobot();
    robot.mouseMove(10, 30);
    robot.mousePress(1);
    
Sergey Grinev
  • 34,078
  • 10
  • 128
  • 141
  • Thank you Sergey. And for the Tray icon, do you have news of some compatible technology that can be used? – betaman Jun 20 '12 at 17:38
  • 3
    The tray icon functionality is not implemented yet. You can track the status of this feature over here: https://javafx-jira.kenai.com/browse/RT-24251 – Petr Mar 27 '13 at 12:52
  • Updated link to JavaFX tray icon feature request mentioned by @Petr: https://bugs.openjdk.java.net/browse/JDK-8092115 – Sebastian S May 15 '17 at 08:21
  • JavaFX 11 now has the public [`javafx.scene.robot.Robot`](https://openjfx.io/javadoc/11/javafx.graphics/javafx/scene/robot/Robot.html) class. – Slaw Feb 05 '19 at 21:49
  • 1
    I provide a small wrapper library for easily adding a tray icon in JavaFX apps. It keeps developers from having to touch the dreaded AWT API. [FXTrayIcon](https://github.com/dustinkredmond/FXTrayIcon) – Dustin Nov 18 '20 at 13:10