dustinkredmond / FXTrayIcon

Tray Icon implementation for JavaFX applications. Say goodbye to using AWT's SystemTray icon, instead use a JavaFX Tray Icon.
MIT License
327 stars 26 forks source link

When another thread is running, some codding stops working! #62

Closed ctoabidmaqbool closed 1 year ago

ctoabidmaqbool commented 1 year ago

For example, I am using this code:

MenuItem mnuSoftVersionStatus = new MenuItem(SOFT_VERSION);
trayIcon.addMenuItem(mnuSoftVersionStatus);

mnuSoftVersionStatus.setText(SOFT_VERSION + " : " + "Starting");
new org.hsqldb.Server().start();
mnuSoftVersionStatus.setText(SOFT_VERSION + " : " + "Running");

After this new org.hsqldb.Server().start(); the mnuSoftVersionStatus.setText() is not working?

ctoabidmaqbool commented 1 year ago

I I use something like this codding, All is working fine

` final PopupMenu popup = new PopupMenu();

TrayIcon trayIcon = new TrayIcon(Toolkit.getDefaultToolkit().createImage(getClass().getResource(ICON))); trayIcon.setPopupMenu(popup);

final SystemTray tray = SystemTray.getSystemTray();

try { tray.add(trayIcon); } catch (AWTException e) { System.out.println("TrayIcon could not be added." + e.getMessage()); }

MenuItem mnuSoftVersionStatus = new MenuItem(SOFT_VERSION); popup.add(mnuSoftVersionStatus);

mnuSoftVersionStatus.setLabel(SOFT_VERSION + " : " + "Starting"); new org.hsqldb.Server().start(); mnuSoftVersionStatus.setLabel(SOFT_VERSION + " : " + "Running");

dustinkredmond commented 1 year ago

I didn't originally intend for the label text to be changed after the MenuItem was added. I will look into implementing a listener to update this on the Event Dispatch thread when attributes of the MenuItems are changed. Thanks for opening this issue!

dustinkredmond commented 1 year ago

@ctoabidmaqbool I believe I've fixed this with commit 992c9b0. Could you please try your original code again with a copy of the source code before I push another release with the fix. I've written a test class and it appears to work on my end.

ctoabidmaqbool commented 1 year ago

@dustinkredmond Hi! I have tried source files, and it's actually works as expected. Thanks

I have some other issues too, will put as separate issues.

dustinkredmond commented 1 year ago

Glad that fixed it! I will close this issue, review the others, then plan on a minor version release by the end of the week to resolve these.