GithubHelp home page GithubHelp logo

dorkbox / systemtray Goto Github PK

View Code? Open in Web Editor NEW
406.0 18.0 57.0 2.38 MB

Cross-platform SystemTray support for Swing/AWT, macOS, GtkStatusIcon, and AppIndicator on Java 8+

License: Other

Java 95.04% JavaScript 1.72% C 1.83% C++ 1.11% Kotlin 0.30%
java systemtray tray-menu swt jna linux tray-icon cross-platform awt swing

systemtray's Introduction

SystemTray

Git Github Gitlab

Professional, cross-platform SystemTray support for Swing/AWT, GtkStatusIcon, and AppIndicator on Java 8+.

This library provides OS Native menus and Swing/AWT menus, depending on the OS and Desktop Environment and if AutoDetect (the default) is enabled.

  • Linux/Unix will automatically choose Native (GtkStatusIcon or AppIndicator) menus, Windows will choose Native (WindowsNotifyIcon with Swing menus), and MacOS will choose AWT.

  • Please note that the Native and AWT menus follow the specified look and feel of that OS and are limited by what is supported on the OS. Consequently they are not consistent across all platforms and environments.

  • In most cases on Linux/Unix, Native menus are used. In cases where libraries are missing or there are un-resolvable GTK version conflicts, we try to fallback to using Swing.

 

The following unique problems are also solved by this library:

  1. Sun/Oracle system-tray icons on Linux/Unix do not support images with transparent backgrounds
  2. Sun/Oracle system-tray and SWT system-tray implementations do not support app-indicators, which are necessary on different distributions of Linux/Unix
  3. GNOME3 desktop environments hide or remove entirely system tray icons (hidden from 3.16-3.25, removed from 3.26+)
  4. Sun/Oracle system-tray menus on Windows look absolutely horrid
  5. Sun/Oracle system-tray icons on Windows are hard-coded to a max size of 24x24 (it was last updated in 2006)
  6. Sun/Oracle AWT system-tray menus on MacOS do not respond to both mouse buttons, where native menus do
  7. Sun/Oracle AWT system-tray menus on MacOS do not support images, where native menus do
  8. Windows native menus do not support images attached to menu entries
  9. Windows menus do not support a different L&F from the running application
  10. Windows L&F is, by default, not the native L&F.
  11. java.awt.Desktop.getDesktop() is broken when using GTK3 or on MacOS.
  12. Windows, Linux, and MacOSX menus (native or otherwise) do not support HiDPI configurations
    1. Java8 is not DPI aware (so the icons + fonts must be scaled appropriately)
    2. Java 11+ is DPI aware, but must be explicitly enabled via native API calls
  13. Gnome/KDE environments no longer show system-tray icons without special shell extensions installed (this library will install and update them automatically)

This is for cross-platform use, specifically - linux 32/64/arm, mac 32/64/arm, and windows 32/64/arm. Java 8+

 
 

Linux

MacOS

Windows

   

Problems and Restrictions

  • JavaFX uses GTK2 for Java <8, and GTK2 or GTK3 for Java 9, and GTK3 for Java 10+. We try to autodetect this, and are mostly successful. In some situations where it doesn't work. Please set SystemTray.FORCE_GTK2=true;, or to change JavaFX (9+), use -Djdk.gtk.version=3 to solve this.

  • SWT can use GTK2, GTK3, or GTK4. We do not support GTK4, and recommend GTK3 (now the default for SWT) If you want to use something else, you must configure both SWT and the SystemTray to same, before SWT is initialized and only if there are problems with the autodetection, via SystemTray.FORCE_GTK2=true;.

  • AppIndicators under Ubuntu 16.04 (and possibly other distro's) will not work as a different user without extra work (ie: as a sudo'd user to root), since AppIndicators require a dbus connection to the current user's window manager. (see the Notes below for the details)

  • MacOSX is a special snowflake in how it handles GUI events, and so there are some bizzaro combinations of SWT, JavaFX, and Swing that do not work together. (see the Notes below for the details)

  • MacOSX original menus cannot display images attached to menu entries. The native implementation supports images. If forced to Swing instead, the tray-menu will no longer support the OS theme and transparancy.

  • Gnome 3: 3.16 - 3.25 (Fedora, Manjaro, Arch, etc) environments by default do not allow the SystemTray icon to be shown. This has been worked around and the tray icon will be placed next to the clock. A different workaround is to install the [Top Icons] (https://extensions.gnome.org/extension/1031/topicons/) plugin which moves icons from the notification drawer sometimes at the bottom left (collapsed) corner of the screen to the menu panel next to the clock.

  • Gnome 3: 3.26+ (Fedora, Manjaro, Arch, etc) environments by default do not allow the SystemTray icon to be shown. This has been worked around and the tray icon will be placed next to the clock. A different workaround is to install the Appindicator Support plugin which allows the addition of app-indicator icons where one would expect. Additionally, you will need to install libappindicator-gtk3.

  • ToolTips The maximum length is 64 characters long, and it is not supported on all Operating Systems and Desktop Environments. Specifically, Swing and GtkStatusIcon types support tray tooltips and menu tooltips. AppIndicator types do not support tooltips of any kind. Please note that Ubuntu uses AppIndicators!

  • Linux/Unix Menus Some Linux environments only support right-click to display the menu, and it is not possible to change the behavior.

  • Linux/Unix and java.awt.Desktop.getDesktop() Please use the dorkbox.util.Desktop class as a replacement, which will intelligently call the correct OS API to open a folder/directory, email, or browser. (Many thanks to QZ Tray for this).

  • WSL Windows Subsystem for Linux requires some extra work to get a tray icon showing correctly, either by starting java under windows (instead of WSL), or by adding an X-Server.

AutoDetect Compatibility List

OS Supported
Arch Linux + Gnome3
Manjaro Linux + KDE
ChromeOS x
Debian 8.5 + Gnome3
Debian 8.6 + Gnome3
Debian 9.5 + Gnome3
Debian 9.5 + KDE
Debian 9.5 + Cinnamon
Debian 9.5 + MATE
Debian 9.5 + LXDE
Debian 9.5 + XFCE
Elementary OS 0.3.2
Elementary OS 0.4
Elementary OS 5.0 *
Fedora 23
Fedora 24
Fedora 25
Fedora 25 KDE
Fedora 26
Fedora 27
Fedora 28
Fedora 29
Fedora 39
FreeBSD 11 + Gnome3
IGEL OS 9.5
Kali 2016
Kali 2017
LinuxMint 18
LinuxMint 19
LinuxMint 20
Ubuntu 12.04
Ubuntu 14.04
Ubuntu 16.04
Ubuntu 17.04
Ubuntu 17.10
Ubuntu 18.04
Ubuntu 20.04
Ubuntu 22.04
UbuntuGnome 16.04
UbuntuGnome 17.04
Kubuntu 23.10
XUbuntu 16.04
MacOSx 10.x
MacOSx 11.x
MacOSx 12.x
MacOSx 13.x
MacOSx 14.x
Windows XP
Windows 7
Windows 8.1
Windows 10
Windows 11
WSL 1 x
WSL 2 x
  • If it is working on an unlisted OS/DE, please let us know!!

Notes:

  • The compatibility list only applies while the SystemTray is in AutoDetect mode. Not all OSes support forcing a custom tray type.

  • Some Linux operating systems with GNOME 3 might require the installation of the app-indicator library as well. We usually provide feedback when this is necessary. (Arch, Fedora, etc)

  • The menu item callbacks occur on their own dispatch thread (instead of being on whatever OS's event dispatch thread), in order to provide consistent actions across all platforms. It is critical to make sure that access to Swing/etc that depend on running events inside their own EDT, are properly called. IE: SwingUtilities.invokeLater(). Do not use invokeAndWait() as weird GUI anomalies can happen.

  • Ubuntu 16.04+ with JavaFX require libappindicator1 because of JavaFX GTK and indicator panel incompatibilities. See more details. We attempt to fallback to using Swing in this situation.

  • Ubuntu 17.04, Java only supports the X11 backend. MIR is not supported.

  • Debian + GNOME 3, SystemTray works, but will only show in a tray via pressing SUPER+M.

  • MacOSX JavaFX (Java7) is incompatible with the SystemTray by default. See issue details.

    • To fix this do one of the following
      • Upgrade to Java 8
      • Add : -Djavafx.macosx.embedded=true as a JVM parameter
      • Set the system property via System.setProperty("javafx.macosx.embedded", "true"); before JavaFX is initialized, used, or accessed. NOTE: You may need to change the class (that your main method is in) so it does NOT extend the JavaFX Application class.
  • SWT builds for FreeBSD do not exist.

  • ElementaryOS 5.0+ removed support for appindicators by just not including a library. You can add it back with here.

  • Linux/Unix: If you want to run this library as a different user, you will need to launch your application via sudo su username /bin/sh -c "DBUS_SESSION_BUS_ADDRESS='unix:abstract=/tmp/dbus-cLtEoBPmgC' XDG_CURRENT_DESKTOP=$XDG_CURRENT_DESKTOP program-name", where unix:abstract=/tmp/dbus-cLtEoBPmgC from /run/user/{uid}/dbus-session. You will also want to disable the root check + warnings via SystemTray.ENABLE_ROOT_CHECK=false; See issue for more details.

  • Linux/Unix: If you want to create a custom menu for the LAUNCHER icon, you must create a custom .desktop shortcut in order to create Actions. Credit to @tresf for figuring this out.

    For example:

    steam launcher screen shot

[Desktop Entry]
Name=Steam
Comment=Application for managing and playing games on Steam
Exec=/usr/bin/steam %U
Icon=steam
Terminal=false
Type=Application
Categories=Network;FileTransfer;Game;
MimeType=x-scheme-handler/steam;
Actions=Store;Community;Library;Servers;Screenshots;News;Settings;BigPicture;Friends;

And then the executable path and language translations are as follows:

[Desktop Action Store]
Name=Store
Name[de]=Shop
Name[es]=Tienda
Name[fr]=Magasin
Name[it]=Negozio
Name[pt]=Loja
Name[ru]=Магазин
Name[zh_CN]=商店
Name[zh_TW]=商店
Exec=steam steam://store

 
 

Customization parameters:

SystemTray.AUTO_SIZE   (type boolean, default value 'true')
 - Enables auto-detection for the system tray. This should be mostly successful.
 
 
SystemTray.APP_NAME   (type String, default value 'SystemTray')
 - Default name of the application, sometimes shows on tray-icon mouse over. Not used for all OSes, but mostly for Linux
   
 
SystemTray.FORCE_GTK2    (type boolean, default value 'false')
 - Forces the system tray to always choose GTK2 (even when GTK3 might be available).
 
 
SystemTray.PREFER_GTK3    (type boolean, default value 'true') 
 - Prefer to load GTK3 before trying to load GTK2.
    

SystemTray.FORCE_TRAY_TYPE   (type SystemTray.TrayType, default value 'AutoDetect')
 - Forces the system tray detection to be AutoDetect, GtkStatusIcon, AppIndicator, WindowsNotifyIcon, Swing, or AWT.
   This is an advanced feature, and it is recommended to leave it at AutoDetect.

 
SystemTray.AUTO_FIX_INCONSISTENCIES    (type boolean, default value 'true')
 -  Allows the SystemTray logic to resolve various OS inconsistencies for the SystemTray in different combinations

 
SystemTray.ENABLE_ROOT_CHECK    (type boolean, default value 'true')
 -  Allows the SystemTray logic to ignore if root is detected. Usually when running as root it will not work (because of 
    how DBUS operates), but in rare situations, it might work.
    This is an advanced feature, and it is recommended to leave as true 
 
 
SystemTray.SWING_UI    (type SwingUIFactory, default value 'null')
 - Allows the developer to provide a custom look and feel for the Swing UI, if defined. See the test example for specific use.
      
 
SystemTray.DEBUG    (type boolean, default value 'false')
 -  This property is provided for debugging any errors in the logic used to determine the system-tray type and initialization feedback.


SizeAndScalingLinux.OVERRIDE_MENU_SIZE    (type int, default value '0')
 - Allows overriding of the LINUX system tray MENU size (this is what shows in the system tray).


SizeAndScalingLinux.OVERRIDE_TRAY_SIZE    (type int, default value '0')
 - Allows overriding of the LINX system tray ICON size (this is what shows in the system tray).


SizeAndScalingMacOS.OVERRIDE_MENU_SIZE    (type int, default value '0')
 - Allows overriding of the MACOS system tray MENU size (this is what shows in the system tray).


SizeAndScalingMacOS.OVERRIDE_TRAY_SIZE    (type int, default value '0')
 - Allows overriding of the MACOS system tray ICON size (this is what shows in the system tray).


SizeAndScalingWindows.OVERRIDE_MENU_SIZE    (type int, default value '0')
 - Allows overriding of the WINDOWS system tray MENU size (this is what shows in the system tray).
 
 
SizeAndScalingWindows.OVERRIDE_TRAY_SIZE    (type int, default value '0')
 - Allows overriding of the WINDWOS system tray ICON size (this is what shows in the system tray).


GtkTheme.TRAY_IMAGE_SIZE_FALLBACK    (type int, default value '24')
 - Fallback for an unknown tray image size for GTK 


GtkTheme.TRAY_MENU_IMAGE_SIZE_FALLBACK    (type int, default value '16')
 - Fallback for an unknown tray menu image size for GTK

The test application is on Git, and a simple example is as follows:

    SystemTray.SWING_UI = new CustomSwingUI();

    SystemTray systemTray = SystemTray.get();
    if (systemTray == null) {
        throw new RuntimeException("Unable to load SystemTray!");
    }
 

    systemTray.setImage("grey_icon.png");
    systemTray.setStatus("Not Running");
    
    systemTray.getMenu().add(new MenuItem("Quit", new ActionListener() {
        @Override
        public
        void actionPerformed(final ActionEvent e) {
            systemTray.shutdown();
            //System.exit(0);  not necessary if all non-daemon threads have stopped.
        }
    })).setShortcut('q'); // case does not matter

 
 

Note: This project was heavily influenced by the excellent Lantern project (when it was Java based),
      *Many* thanks to them for figuring out AppIndicators via JNA.
      https://github.com/getlantern/lantern
Note: Gnome-shell users can install an extension to support placing the tray icon next to all 
      of other OS tray icons. By default, all tray icons go to a "Notification drawer" which 
      is initially hidden. 
Note: We have fixed the Swing notification tray on Linux (it no longer has a greyish background), however
      to facilitate this, a screen-shot is grabbed where the icon is. Because this must happen after the
      icon is placed, *sometimes* you can see this happen. Unfortunately this is the only way to fix
      this problem, and there are no other known workarounds outside of writing an X11 wrapper from scratch.

 
 

ISSUES:
      'Trying to remove a child that doesn't believe we're it's parent.'
      
      This is a known appindicator bug, and is rather old. Some distributions use 
      an OLD version of libappindicator, and will see this error. 
         See: https://github.com/ValveSoftware/steam-for-linux/issues/1077
      -----------------------   
         
         
      'gsignal.c: signal 'child-added' is invalid for instance 'xyz' of type 'GtkMenu''
      
      This is a known appindicator bug, and is rather old. Some distributions use an 
      OLD version of libappindicator, and will see this error. 
      
      The fallout from this issue (ie: menu entries not displaying) has been 
      *worked around*, so the menus should still show correctly.
         See: https://askubuntu.com/questions/364594/has-the-appindicator-or-gtkmenu-api-changed-in-saucy
      -----------------------   
         
         
      Gdk-WARNING XSetErrorHandler() called with a GDK error trap pushed. Don't do that.
      
      This is a bug specifically with JavaFX +GTK3. From what I can tell, this not something that can be fixed.
        (bugs)
        https://stackoverflow.com/questions/55446534/how-to-fix-java22494-gdk-warning
        https://bugs.openjdk.java.net/browse/JDK-8156779
        https://bugs.openjdk.java.net/browse/JDK-8211305

        (Source files)
        https://github.com/openjdk/jfx/blob/master/modules/javafx.graphics/src/main/java/com/sun/glass/ui/gtk/GtkApplication.java
        https://github.com/openjdk/jfx/blob/master/modules/javafx.graphics/src/main/native-glass/gtk/GlassApplication.cpp

        (Where the error occurs)
        https://gitlab.gnome.org/GNOME/gtk/-/blob/master/gdk/x11/gdkmain-x11.c
  

   

Maven Info

<dependencies>
    ...
    <dependency>
      <groupId>com.dorkbox</groupId>
      <artifactId>SystemTray</artifactId>
      <version>4.5</version>
    </dependency>
</dependencies>

Gradle Info

dependencies {
    ...
    implementation("com.dorkbox:SystemTray:4.5")
}

License

This project is © 2023 dorkbox llc, and is distributed under the terms of the Apache v2.0 License. See file "LICENSE" for further references.

systemtray's People

Contributors

denuno avatar dorkbox avatar nohus avatar pietrygamat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

systemtray's Issues

Why not use Swing containers?

Moved from an conversation that started on a downstream PR.

tresf wrote: I'm not particularly fond of the fact that dorkbox has chosen to reimpliment his own menu items instead of extending that which Swing already offers. I'd rather not have dorkbox components spread all around the classes simply because he fails to implement JMenuItem or AbstractButton.

dorkbox wrote: @tresf I agree with you most of the time, but a tiny nit --- The SystemTray doesn't use Swing components for it's API (JMenu, AbstractButton, or their sub-classes) because there is undefined behavior if they were to be used without a java native peer and there is an expectation otherwise. This is an important distinction because the SystemTray menus and entries do not always have java native peers the way those objects expect. I know that you understand the difference, but a quick google search for "java system tray" shows that there problems going back more than 10+ years on this topic.

Given that a good deal of the menu system and event dispatch had to be re-implemented in a cross-platform way, I felt the best solution was a clean and concise API that doesn't leave room for ambiguity or undefined behavior. For example, if one examines the source of AbstractButton and compares it to the source for MenuItem (or Entry), it should make sense.

Admittedly, it pains me that the JMenu, etc components could not be re-used in a safe and clean way - as I wanted the SystemTray to be as easy for developers to use as possible, and would have preferred a 100% "drop in" replacement; ultimately the decision was reached to make sure it is absolutely clear that it is neither a Swing nor JavaFX menu. For the majority of the time, a simple change from JMenu -> Menu is sufficient, as I mirrored as much of the Swing API that was applicable.

Please understand it wasn't a failure or ignoring advice/input, but rather a careful move on the side of caution to prevent undefined behavior and maintain a clean API.

@dorkbox can you explain why a swing-compatible container is a no-go?

I know that you understand the difference,

I don't think that I do. From my very basic understanding, the library could wrap the commonly used Swing containers so that features like setToolTipText would be natively exposed when available (regardless of whether or not the underlying JNA supports it). What is it about the JMenuItem container that can't be used to carry the icons, state, tooltip text, mnemonics, etc?

GLib-GObject-WARNING **: cannot register existing type 'GdkDisplayManager'

The following code crashes but also hangs, ignoring the try..catch.

package test.dorkbox.systray;

import dorkbox.systemTray.SystemTray;
import java.awt.Dimension;
import javax.swing.JFrame;
import javax.swing.JSlider;
import javax.swing.UIManager;
import javax.swing.UIManager.LookAndFeelInfo;

@SuppressWarnings("serial")
public class TestFrame extends JFrame {

    public TestFrame() {

        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setSize(new Dimension(200, 100));
        setLocationRelativeTo(null);
        setTitle("Test");
        setAlwaysOnTop(true);
        setResizable(false);

        JSlider slider = new JSlider(0, 100, 50);
        add(slider);

        try {
            SystemTray.getSystemTray();
        } catch (Exception ex) {
            System.err.println(ex);
        }
    }

    private static void setLookAndFeel(final String laf) {
        try {
            for (final LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
                if (laf.equals(info.getClassName())) {
                    UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (Exception ex) {
            System.err.println(ex);
        }
    }

    private static void setNativeLookAndFeel() {
        setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    }

    public static void main(String args[]) {
        setNativeLookAndFeel();
        System.out.println("LAF = " + UIManager.getLookAndFeel());
        java.awt.EventQueue.invokeLater(() -> {
            new TestFrame().setVisible(true);
        });
    }

}

Running this in Netbeans on Linux Mint 17.3 generates the error -

[AWT-EventQueue-0] ERROR dorkbox.systemTray.SystemTray - Unable to load the system tray native library. Please write an issue and include your OS type and configuration

(java:16435): GLib-GObject-WARNING **: cannot register existing type 'GdkDisplayManager'

(java:16435): GLib-CRITICAL **: g_once_init_leave: assertion 'result != 0' failed

(java:16435): GLib-GObject-CRITICAL **: g_object_new: assertion 'G_TYPE_IS_OBJECT (object_type)' failed

I then have to manually stop the process from the IDE.

If I comment out the call to setNativeLookAndFeel() then SystemTray.getSystemTray(); works but I get the default look and feel -
screenshot from 2016-11-30 10 51 14

If I comment out SystemTray.getSystemTray(); instead then setNativeLookAndFeel() works and the dialog looks like -
screenshot from 2016-11-30 10 50 41

I tried adding the SystemTray.COMPATIBILITY_MODE=true and System.setProperty("SWT_GTK3", "0") but these made no difference.

Even if there is no solution I think it should at least honour the try..catch wrapper so that it can fail gracefully.

Specs

SystemTray-2.20.jar
SystemTray-Dorkbox-Util-2.20.jar
jna-4.2.2.jar
java version "1.8.0_111"
Netbeans 8.1
Linux Mint 17.3

Feature requests

Hello,

I had some features in mind that could be useful

  • Submenu's
  • Possibility to add empty lines to keep things organized / to add non-clickable texts.

Thanks for making this library, it's really helpful because the default looks like windows 2003 on Linux 😄

Release Candidate 3.0 status/issues

Current Release Candidate: 10

For system compatibility on release, please use the system_tray_3.0.jar -- this file is the same format that the release will be in. For all-in-one "FAT" jars, use the RCx.jars.

RC10: Fixed issue/added support for Swing UI menu/entry customization independent of system L&F.

RC9: Removed getNative() and getSwing(). There is only get(), which will choose native,Swing, or AWT depending on OS. This can be customized (see readme)

RC8: Fixed crash on Windows java 32bit with injecting bytecode.

RC7: Small API changes from RC6 -> RC7: SystemTray.get() is now SystemTray.getSwing() to indicate it's menu type (Similarly to getNative()), and to indicate that there is no library preference between the two different methods.

The Release Candidate downloads is released as a "all-in-one" jar, for a variety of different tray types and configurations. Please note that SWT testing will require you to download the SWT native library and add it to the classpath when you launch the jar. If you use SWT, you should be familiar with this, otherwise don't worry about it.

There shouldn't be any issues for any of the OS' listed in the Compatibility Matrix. If you are testing this and your OS isn't listed, please open a new issue for it.

Finally, the jars can be tested via java -jar SystemTray_RC2_normal.jar (as an example).

EDIT: I've cleaned up this thread a bit, it was becoming big. After the Release Candidate passes, this issue will be closed.

Look and feel defaults to Nimbus on Windows

With the latest Beta, Windows defaults to Nimbus Look and Feel (CrossPlatformLookAndFeel) whereas I would like to specifically set it to the Windows theme (SystemLookAndFeel)or something else of my choosing.

image

No menu entry exists for string '...'

Hi,

I am wondering if anyone has encountered a similar issue:
Sometimes, when updateMenuEntry is called after addMenuEntry is, an exception occurs (No menu entry exists for string...). Is this some kind of a threading issue ? How can I check that a menu entry indeed exists before trying to update it ?

Thanks.

SysTrayIcon not showing up on Fedora

I'm using the same code as on Win/Mac and Xubuntu, however on Fedora the following error appears:

Gdk-CRITICAL **: gdk_window_thaw_toplevel_updates: assertion 'window->update_and_descendants_freeze_count > 0' failed

I'm on Fedora 4.2.3-300.fc23.x86_64

Any ideas ? Thanks.

menu is not instanceof _GtkStatusIconNativeTray?

When I call shutdown() on the SystemTray, it throws a NullPointerException. A stacktrace shows that it was trying to call ((_SwingTray)menu).shutdown(), but the log says it should be calling ((_GtkStatusIconNativeTray)menu).shutdown(), as it is recognized as that type of tray. Dunno why it's not that type of tray, but yeah.

/usr/lib/jvm/default/bin/java -Didea.launcher.port=7534 -Didea.launcher.bin.path=/usr/share/intellijidea-ce/bin -Dfile.encoding=UTF-8 -classpath /usr/lib/jvm/default/jre/lib/charsets.jar:/usr/lib/jvm/default/jre/lib/deploy.jar:/usr/lib/jvm/default/jre/lib/ext/cldrdata.jar:/usr/lib/jvm/default/jre/lib/ext/dnsns.jar:/usr/lib/jvm/default/jre/lib/ext/jaccess.jar:/usr/lib/jvm/default/jre/lib/ext/jfxrt.jar:/usr/lib/jvm/default/jre/lib/ext/localedata.jar:/usr/lib/jvm/default/jre/lib/ext/nashorn.jar:/usr/lib/jvm/default/jre/lib/ext/sunec.jar:/usr/lib/jvm/default/jre/lib/ext/sunjce_provider.jar:/usr/lib/jvm/default/jre/lib/ext/sunpkcs11.jar:/usr/lib/jvm/default/jre/lib/ext/zipfs.jar:/usr/lib/jvm/default/jre/lib/javaws.jar:/usr/lib/jvm/default/jre/lib/jce.jar:/usr/lib/jvm/default/jre/lib/jfr.jar:/usr/lib/jvm/default/jre/lib/jfxswt.jar:/usr/lib/jvm/default/jre/lib/jsse.jar:/usr/lib/jvm/default/jre/lib/management-agent.jar:/usr/lib/jvm/default/jre/lib/plugin.jar:/usr/lib/jvm/default/jre/lib/resources.jar:/usr/lib/jvm/default/jre/lib/rt.jar:/usr/lib/jvm/default/lib/ant-javafx.jar:/home/ash/Projects/IdeaProjects/emojikeyboard-java/build/classes/main:/home/ash/Projects/IdeaProjects/emojikeyboard-java/build/resources/main:/home/ash/.gradle/caches/modules-2/files-2.1/com.google.code.gson/gson/2.7/751f548c85fa49f330cecbb1875893f971b33c4e/gson-2.7.jar:/home/ash/.gradle/caches/modules-2/files-2.1/org.apache.lucene/lucene-analyzers-common/6.2.1/8e08c604b610cdb91b898c841e8a8254b0f020dc/lucene-analyzers-common-6.2.1.jar:/home/ash/.gradle/caches/modules-2/files-2.1/org.apache.commons/commons-lang3/3.4/5fe28b9518e58819180a43a850fbc0dd24b7c050/commons-lang3-3.4.jar:/home/ash/.gradle/caches/modules-2/files-2.1/org.apache.lucene/lucene-core/6.2.1/a1d9ed9e06072fefa13b070628269ccc0a90d7cc/lucene-core-6.2.1.jar:/home/ash/.gradle/caches/modules-2/files-2.1/commons-collections/commons-collections/3.2.2/8ad72fe39fa8c91eaaf12aadb21e0c3661fe26d5/commons-collections-3.2.2.jar:/home/ash/Projects/IdeaProjects/emojikeyboard-java/libs/SystemTray_v2.20_normal.jar:/usr/share/intellijidea-ce/lib/idea_rt.jar com.intellij.rt.execution.application.AppMain net.ashyon.emojikeyboard.Main
Gtk-Message: (for origin information, set GTK_DEBUG): failed to retrieve property `gtk-primary-button-warps-slider' of type `gboolean' from rc file value "((GString*) 0x7f55780a06e0)" of type `gboolean'
09:58:34.098 [JavaFX Application Thread] DEBUG dorkbox.systemTray.SystemTray - OS: Linux
09:58:34.102 [JavaFX Application Thread] DEBUG dorkbox.systemTray.SystemTray - Arch: amd64
09:58:34.102 [JavaFX Application Thread] DEBUG dorkbox.systemTray.SystemTray - is AutoTraySize? true
09:58:34.102 [JavaFX Application Thread] DEBUG dorkbox.systemTray.SystemTray - is JavaFX detected? true
09:58:34.102 [JavaFX Application Thread] DEBUG dorkbox.systemTray.SystemTray - is SWT detected? false
09:58:34.102 [JavaFX Application Thread] DEBUG dorkbox.systemTray.SystemTray - is using native menus? true
09:58:34.104 [JavaFX Application Thread] DEBUG dorkbox.systemTray.SystemTray - Forcing GTK2 because JavaFX is GTK2
09:58:34.104 [JavaFX Application Thread] DEBUG dorkbox.systemTray.SystemTray - Auto-detecting tray type
09:58:34.104 [JavaFX Application Thread] DEBUG dorkbox.systemTray.SystemTray - FORCE_GTK2: true
09:58:34.162 [JavaFX Application Thread] DEBUG dorkbox.systemTray.SystemTray - GTK: gtk-x11-2.0
09:58:34.162 [JavaFX Application Thread] DEBUG dorkbox.systemTray.SystemTray - Is the system already running GTK? true
09:58:34.162 [JavaFX Application Thread] DEBUG dorkbox.systemTray.SystemTray - Loading libraries
09:58:34.188 [JavaFX Application Thread] ERROR dorkbox.systemTray.SystemTray - Auto-detected that gnome-shell is running
09:58:34.188 [JavaFX Application Thread] DEBUG dorkbox.systemTray.SystemTray - Currently using the 'gnome' desktop
09:58:34.189 [JavaFX Application Thread] DEBUG dorkbox.systemTray.SystemTray - Currently using the 'gnome-xorg' session type
09:58:34.213 [JavaFX Application Thread] ERROR dorkbox.systemTray.SystemTray - Unable to load the system tray native library. Please write an issue and include your OS type and configuration
09:58:34.225 [JavaFX Application Thread] DEBUG dorkbox.systemTray.SystemTray - Checking scaling factor for GTK environment, should start with 'uint32', value: 'uint32 0
'
09:58:34.278 [JavaFX Application Thread] INFO dorkbox.systemTray.SystemTray - Successfully Loaded: _GtkStatusIconNativeTray
Exception in thread "JavaFX Application Thread" java.lang.NullPointerException
    at dorkbox.systemTray.SystemTray.shutdown(SystemTray.java:697)
    at dorkbox.systemTray.SystemTray$2.run(SystemTray.java:611)
    at com.sun.javafx.tk.Toolkit.notifyShutdownHooks(Toolkit.java:476)
    at com.sun.javafx.tk.quantum.QuantumToolkit.exit(QuantumToolkit.java:756)
    at com.sun.javafx.application.PlatformImpl.lambda$tkExit$178(PlatformImpl.java:450)
    at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326)
    at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
    at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
    at com.sun.glass.ui.gtk.GtkApplication.lambda$null$49(GtkApplication.java:139)
    at java.lang.Thread.run(Thread.java:745)

GTK versions conflict

Hi,

When I try to use java.awt.Desktop on Xubuntu x64 14.04 the following error pops up:

Gtk-ERROR **: GTK+ 2.x symbols detected. Using GTK+ 2.x and GTK+ 3 in the same process is not supported

Any ideas how to avoid this conflict ?

Fatal Error on Ubuntu Gnome 16.04 Desktop

JVM crashes if I try to access MenuEntry by click on icon.
I'm receiving same message of issue #19
and need to put setIcon BEFORE addMenuEntry to not freeze my app.
But now my app don't freeze, it crashs :)

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007f071470ad84, pid=2426, tid=0x00007f06baeca700
#
# JRE version: Java(TM) SE Runtime Environment (8.0_101-b13) (build 1.8.0_101-b13)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.101-b13 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# C  [libpthread.so.0+0x9d84]  pthread_mutex_lock+0x4
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

---------------  T H R E A D  ---------------

Current thread (0x00007f070c428800):  JavaThread "GTK Native Event Loop" [_thread_in_native, id=2450, stack(0x00007f06badca000,0x00007f06baecb000)]

siginfo: si_signo: 11 (SIGSEGV), si_code: 128 (SI_KERNEL), si_addr: 0x0000000000000000

Registers:
RAX=0x00007f06f6487370, RBX=0x000000000073e6a0, RCX=0x00000000000000d2, RDX=0x00007f06baec5410
RSP=0x00007f06baec5380, RBP=0x00007f06baec53f0, RSI=0x00007f06baec5400, RDI=0x7475426e6970536b
R8 =0x00007f06baec53f0, R9 =0x00007f070c3ad460, R10=0x00007f06f650c447, R11=0x0000000000000065
R12=0x00007f06baec53ec, R13=0x0000000000000000, R14=0x0000000000753e68, R15=0x00007f06baec6980
RIP=0x00007f071470ad84, EFLAGS=0x0000000000010202, CSGSFS=0x0000000000000033, ERR=0x0000000000000000
  TRAPNO=0x000000000000000d

Top of Stack: (sp=0x00007f06baec5380)
0x00007f06baec5380:   212074786574004c 00007f06f64a1bfa
0x00007f06baec5390:   00007f06baec5400 00007f06baec5410
0x00007f06baec53a0:   0000000000000000 00000000006ec150
0x00007f06baec53b0:   00007f06cec8f161 b170dd48cc475d00
0x00007f06baec53c0:   00000000006ec150 00007f06cec8f161
0x00007f06baec53d0:   00007f06cec90974 00007f06f647df86
0x00007f06baec53e0:   00007f0700000002 00007f06cdc78b23
0x00007f06baec53f0:   0000000000752c00 0000000000000992
0x00007f06baec5400:   000000d4000000d2 00007f0600000000
0x00007f06baec5410:   000000dd000000dc 0000000000000000
0x00007f06baec5420:   0000000000000000 b170dd48cc475d00
0x00007f06baec5430:   00000000007538d0 0000000000753904
0x00007f06baec5440:   00000000006ec150 00007f06cec4993f
0x00007f06baec5450:   0000000000807c20 0000000000000001
0x00007f06baec5460:   0000000000752c00 b170dd48cc475d00
0x00007f06baec5470:   00007f06baec55c0 000000000080ef28
0x00007f06baec5480:   00007f06baec54e0 000000000080ef28
0x00007f06baec5490:   0000000000000000 0000000000753e68
0x00007f06baec54a0:   00007f06baec6980 00007f06cec4be60
0x00007f06baec54b0:   000000000080ee00 00007f06cec1d627
0x00007f06baec54c0:   0000000000753e68 0000000000807cb0
0x00007f06baec54d0:   00007f06baec5500 00007f06cebdbcff
0x00007f06baec54e0:   0000000000000004 0000000000000014
0x00007f06baec54f0:   0000000000000000 0000000000000000
0x00007f06baec5500:   0000000000000000 00007f06cdc7843a
0x00007f06baec5510:   0000000000000000 0000000000000000
0x00007f06baec5520:   0000000000000000 00007f06f4e30f38
0x00007f06baec5530:   0000000100000000 b170dd48cc475d00
0x00007f06baec5540:   0000000000753ca0 0000000000807cb0
0x00007f06baec5550:   0000000000000050 00007f06cebdee13
0x00007f06baec5560:   0000000000000018 000000000077f070
0x00007f06baec5570:   0000000000000005 00000004cc475d00 

Instructions: (pc=0x00007f071470ad84)
0x00007f071470ad64:   f0 02 00 00 00 00 00 00 b8 82 00 00 00 e9 d8 f9
0x00007f071470ad74:   ff ff 66 2e 0f 1f 84 00 00 00 00 00 48 83 ec 08
0x00007f071470ad84:   8b 57 10 89 d1 81 e1 7f 01 00 00 90 89 d0 83 e0
0x00007f071470ad94:   7c 0f 85 95 00 00 00 85 c9 49 89 f8 0f 85 9a 00 

Register to memory mapping:

RAX=0x00007f06f6487370: <offset 0x2b370> in /usr/lib/x86_64-linux-gnu/libX11.so.6 at 0x00007f06f645c000
RBX=0x000000000073e6a0 is an unknown value
RCX=0x00000000000000d2 is an unknown value
RDX=0x00007f06baec5410 is pointing into the stack for thread: 0x00007f070c428800
RSP=0x00007f06baec5380 is pointing into the stack for thread: 0x00007f070c428800
RBP=0x00007f06baec53f0 is pointing into the stack for thread: 0x00007f070c428800
RSI=0x00007f06baec5400 is pointing into the stack for thread: 0x00007f070c428800
RDI=0x7475426e6970536b is an unknown value
R8 =0x00007f06baec53f0 is pointing into the stack for thread: 0x00007f070c428800
R9 =0x00007f070c3ad460 is an unknown value
R10=0x00007f06f650c447: <offset 0xb0447> in /usr/lib/x86_64-linux-gnu/libX11.so.6 at 0x00007f06f645c000
R11=0x0000000000000065 is an unknown value
R12=0x00007f06baec53ec is pointing into the stack for thread: 0x00007f070c428800
R13=0x0000000000000000 is an unknown value
R14=0x0000000000753e68 is an unknown value
R15=0x00007f06baec6980 is pointing into the stack for thread: 0x00007f070c428800


Stack: [0x00007f06badca000,0x00007f06baecb000],  sp=0x00007f06baec5380,  free space=1004k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  [libpthread.so.0+0x9d84]  pthread_mutex_lock+0x4
C  0x0000000000000992

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j  dorkbox.systemTray.linux.jna.Gtk.gtk_main()V+0
j  dorkbox.systemTray.linux.jna.Gtk.access$300()V+0
j  dorkbox.systemTray.linux.jna.Gtk$1.run()V+34
v  ~StubRoutines::call_stub

cannot get it working on xubuntu 15.04

I'm not sure what I'm doing wrong, since I do not understand jni. Library in system is existing, but cannot be loaded (I think). I'm running amd64 machine with amd64 java patched with font infinality(nicer fornts).

/usr/lib/jvm/java-1.8.0-openjdk-amd64/bin/java -Didea.launcher.port=7533 -Didea.launcher.bin.path=/home/kino/programs/idea/bin -Dfile.encoding=UTF-8 -classpath /usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/lib/charsets.jar:/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/lib/management-agent.jar:/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/lib/jsse.jar:/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/lib/jfxswt.jar:/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/lib/resources.jar:/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/lib/jce.jar:/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/lib/rt.jar:/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/lib/ext/sunjce_provider.jar:/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/lib/ext/nashorn.jar:/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/lib/ext/icedtea-sound.jar:/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/lib/ext/sunpkcs11.jar:/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/lib/ext/sunec.jar:/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/lib/ext/zipfs.jar:/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/lib/ext/jfxrt.jar:/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/lib/ext/java-atk-wrapper.jar:/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/lib/ext/dnsns.jar:/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/lib/ext/cldrdata.jar:/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/lib/ext/localedata.jar:/home/kino/Documents/projects/redmineClient/out/production/redmineClient:/home/kino/Documents/projects/redmineClient/lib/SystemTray_v1.0.jar:/home/kino/Documents/projects/redmineClient/lib/slf4j-api-1.7.5.jar:/home/kino/Documents/projects/redmineClient/lib/dorkboxUtil_v1.0.jar:/home/kino/Documents/projects/redmineClient/lib/jna/jna-4.1.0.jar:/home/kino/Documents/projects/redmineClient/lib/jna/jna-platform-4.1.0.jar:/home/kino/programs/idea/lib/idea_rt.jar com.intellij.rt.execution.application.AppMain cz.kinovic.redmineClient.Main
Fontconfig warning: "/etc/fonts/infinality/conf.d/41-repl-os-win.conf", line 148: Having multiple values in <test> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/infinality/conf.d/41-repl-os-win.conf", line 160: Having multiple values in <test> isn't supported and may not work as expected
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Exception in thread "main" java.lang.UnsatisfiedLinkError: com.sun.jna.Native.sizeof(I)I
    at com.sun.jna.Native.sizeof(Native Method)
    at com.sun.jna.Native.<clinit>(Native.java:132)
    at dorkbox.util.jna.linux.Gtk.<clinit>(Gtk.java:12)
    at dorkbox.util.jna.linux.GtkSupport.<clinit>(GtkSupport.java:11)
    at dorkbox.util.tray.SystemTray.<clinit>(SystemTray.java:76)
    at cz.kinovic.redmineClient.Main.main(Main.java:19)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
locate libgtk-x11-2.0.so
/usr/lib/i386-linux-gnu/libgtk-x11-2.0.so.0
/usr/lib/i386-linux-gnu/libgtk-x11-2.0.so.0.2400.27
/usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0
/usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0.2400.27

UI manager support ( LINUX )

I cant make it work using look and feel customization.
is it supports UI manager ?

UIManager.setLookAndFeel() seams to be my problem.
I tried to set SWT_GTK var and use the tips of the wiki with no success so far.

Cheers.

Tracing the errors:
(java:8658): GLib-GObject-WARNING **: cannot register existing type 'GdkDisplayManager'

(java:8658): GLib-CRITICAL **: g_once_init_leave: assertion 'result != 0' failed

(java:8658): GLib-GObject-CRITICAL **: g_object_new: assertion 'G_TYPE_IS_OBJECT (object_type)' failed

3.1 - Consider blank menu icons

On all major Ubuntu versions, when a menu is constructed with an icon, it shifts the text to the right.
For items without menu icons, they appear shifted to the left.

In the event icons are used, I would like to propose the consideration of re-building the menu with blank icons for items without, for better alignment (or an API method to do this). ElementaryOS seems to do this too.

The menu items "Automatically start", "Block anonymous requests" and "Show all notifications" suffer this problem.

If this is a technical limitation, please close as won't-fix.

Ubuntu 12.04

image

Ubuntu 14.04:

image

Ubuntu 16.04:

image

Windows cannot use the 'AutoDetect' SystemTray type, defaulting to Swing

Is there a recommended approach as to not receive benign warnings in our logs? We're just using "plain old" SystemTray.get();, I wouldn't expect warnings if this is the default usage.

Although warnings seem minor, for projects which rely on users submitting logs for support purposes, they only expect to see warnings that they've created or are valid as to the performance of the software.

Library overriding default logging level

My application uses log4j for system logging; identical versions and dependencies as SystemTray library.

Internally, we place a log4j.xml file on our classpath (we put it in the base of our /src directory) and it gives us granular access over log verbosity.

This technique works well until we embed the system_tray_RC9_normal.jar into our project. The technique we use for bundling our own JAR is ant's zipgroupfileset, which places all of our library dependencies into a single, large jar. We currently do this for 40 separate jar dependencies without issue.

However, once we add system_tray_RC9_normal.jar the verbosity changes. Some of the library we use are very (very) chatty on DEBUG or TRACE level (specifically Jetty), so this will quickly inflate our logs with information we are not particularly concerned with.

Is anyone else experiencing the SystemTray overriding Log4j preferences? How is this happening? Is there a log4j.xml somewhere inside the project that I just cannot find?

I apologize in advance if this is a non-issue, but I'm struggling to obtain sane debug settings with my own code once integrated with SystemTray.

Related article: http://stackoverflow.com/a/14262101/3196753

2.1: [BUG] Not working with both GTK3 and JavaFX

After adding support for GTK3, I have same bug on startup as when using SWT:

(java:2033): GLib-GObject-WARNING **: cannot register existing type 'GdkDisplayManager'

(java:2033): GLib-CRITICAL **: g_once_init_leave: assertion 'result != 0' failed

(java:2033): GLib-GObject-CRITICAL **: g_object_new: assertion 'G_TYPE_IS_OBJECT (object_type)' failed

I don't know I you can fix this, so please add option for disabling support for GTK3.

No transparency with openjdk

The icon looks perfect using Oracle JDK. But my users want to use OpenJDK. The icon than displayed has no transparency, just like the default Swing systray icon.

Environment: Ubuntu 15.10 with Unity 7 and GGleb/indicator-systemtray-unity, OpenJDK 8

GitHub and Maven Version identical?

Hello,

are the current GitHub Version and Maven Version identical?

The Maven Version 2.20 has no getNative() or get() Method. Only getSystemTray().

Can you help me?

Menu items listeners not working on Linux

Menu shows up and open correctly, but clicking menu items with any button does nothing :(

Same code works flawlessly on Windows.


BTW: I can't find version 1.11 form README on any maven repository.

Allow adding images from `InputStream` parameter

All methods for setting icons accepts String instead of URL (or even InputStream), making this task very hard...

I could even fix this myself and create PR, but you not released how to build this project into that two JARs available on maven.

Getting error when I right click the tray icon

I'm running KDE Plasma 5.4 on Manjaro Linux 64-bit.

So I used the example in your README.md and I can see the tray icon but I can't right click. When I right click, I get the following error:

(java:27561): LIBDBUSMENU-GLIB-WARNING **: About to Show called on an item wihtout submenus. We're ignoring it.

Here's a link to the repo if needed: https://github.com/tgharib/PrayerApp

The relevant line of code: https://github.com/tgharib/PrayerApp/blob/master/src/main/java/com/github/tgharib/PrayerFrame.java#L98

Menu separator missing macOS

Using SystemTray.get().getMenu().add(new Separator());, it doesn't seem to appear on macOS.

This logic works fine using a standard awt menu.

image

Add utils class for Gtk collisions

Since a lot of the recent work involved in perfecting this library has gone into dodging Gtk2/3 collisions, I recommend providing a utils-type class for wrapping common collision items.

For starters, the Desktop.getDesktop() is a dangerous call that needs to be safeguarded against. Although we shouldn't override the system default, we can provide a helper to do the dodging for the end-user.

For example, if one wants to open the default email application, the standard method will crash when running Gtk3. Coincidentally, this fix is already needed for certain nuances with the JDK on certain desktop environments, so to catch both scenarios, I've intentionally used throw to wrap both use-cases.

Pseudo-code provided. The design and implementation may extend the java.awt.Desktop class for consistency purposes, etc.

// e.g. function void dorkbox.utils.getDesktop.mail(URI uri) {

try {
   if (dorkbox.systemTray.jna.linux.Gtk.isGtk3) {
      throw new IOException("Avoiding Gtk2/3 collision");
   }
   Desktop.getDesktop().mail(uri);
} catch (IOException io) {
   // Some linux versions throw this naturally; Also catch intentional throw() above.
   // FIXME:  SystemUtilities and ShellUtilities would be replaced with dorkbox equivelents
   if (SystemUtilities.isUnix() && ShellUtilities.execute(new String[] {"xdg-email", uri.toString()})) {
      return;
   }
   throw io;  // rethrow original exception so that we don't steal non-Gtk3 exceptions!
}

Major offenders (from my own experience, there are likely others):

  • UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());, specifically GTKLookAndFeel
  • Desktop.getDesktop().browse(...)
  • Desktop.getDesktop().mail(...)
  • Desktop.getDesktop().open(...)

edit: formatting into a list

Javassist hidden Dependency

Dependency bug:

I needed to include dependency on my project:

<dependency>
    <groupId>javassist</groupId>
    <artifactId>javassist</artifactId>
    <version>3.12.1.GA</version>
</dependency>

The lib doesn't contains any maven dependency information...

Inconsistent Icon Sizes

If this is a technical limitation, please feel free to close as wont-fix, but I wanted to provide some visual feedback for Ubuntu 12.04, 14.04, 16.04.

  • 12.04 seems small.
  • 14.04 seems just right.
  • 16.04 seems cutoff.

Ubuntu 12.04

image

Ubuntu 14.04:

image

Ubuntu 16.04:

image

XFCE Icon disappears after two seconds

Hello,
when I setup the SystemTray like this

SystemTray.DEBUG = true;
SystemTray.COMPATIBILITY_MODE=true;
SystemTray.FORCE_GTK2 = false;
SystemTray.FORCE_LINUX_TYPE = 1;
SystemTray tray = SystemTray.getSystemTray();
URL urk = this.getClass().getResource("/com.flashtek.name/icon.png");
tray.setIcon(urk);
//adding menu items

the icon appears in the taskbar on my XFCE Desktop, but after ~2seconds the icon will always disappear. After setting SystemTray.FORCE_GTK2 = true; this problem is vanished. But sadly this is no option because I later need to use the Dekstop.isDesktopSupported() method which will then cause the entire program to crash with a GRK-ERROR (because the application is now using GTK 3 and 2).

How can I solve this problem or is this a real issue of the library?
Regards,
FlashTek

Implement tooltips for Swing

Although the tray icon supports the tooltip since ec9499c, the JMenuItem's still do not.

Why use tooltips for menus? Well, Microsoft uses it for some ribbon menu items, such as "Open command prompt" item. Google Drive uses it for displaying full paths for files.

The decision may be made to not support them at all and that is fine, but it may be considered a regression on Windows for those coming from JXTrayIcon and friends.

Error using latest beta with JavaFX and Gnome 3

/usr/lib/jvm/default/bin/java -Didea.launcher.port=7535 -Didea.launcher.bin.path=/usr/share/intellijidea-ce/bin -Dfile.encoding=UTF-8 -classpath /usr/lib/jvm/default/lib/ant-javafx.jar:/usr/lib/jvm/default/jre/lib/charsets.jar:/usr/lib/jvm/default/jre/lib/ext/cldrdata.jar:/usr/lib/jvm/default/jre/lib/ext/dnsns.jar:/usr/lib/jvm/default/jre/lib/ext/jaccess.jar:/usr/lib/jvm/default/jre/lib/ext/jfxrt.jar:/usr/lib/jvm/default/jre/lib/ext/localedata.jar:/usr/lib/jvm/default/jre/lib/ext/nashorn.jar:/usr/lib/jvm/default/jre/lib/ext/sunec.jar:/usr/lib/jvm/default/jre/lib/ext/sunjce_provider.jar:/usr/lib/jvm/default/jre/lib/ext/sunpkcs11.jar:/usr/lib/jvm/default/jre/lib/ext/zipfs.jar:/usr/lib/jvm/default/jre/lib/jce.jar:/usr/lib/jvm/default/jre/lib/jfxswt.jar:/usr/lib/jvm/default/jre/lib/jsse.jar:/usr/lib/jvm/default/jre/lib/management-agent.jar:/usr/lib/jvm/default/jre/lib/resources.jar:/usr/lib/jvm/default/jre/lib/rt.jar:/home/ash/Projects/IdeaProjects/emojikeyboard-java/build/classes/main:/home/ash/Projects/IdeaProjects/emojikeyboard-java/build/resources/main:/home/ash/.gradle/caches/modules-2/files-2.1/com.google.code.gson/gson/2.7/751f548c85fa49f330cecbb1875893f971b33c4e/gson-2.7.jar:/home/ash/.gradle/caches/modules-2/files-2.1/commons-collections/commons-collections/3.2.2/8ad72fe39fa8c91eaaf12aadb21e0c3661fe26d5/commons-collections-3.2.2.jar:/home/ash/.gradle/caches/modules-2/files-2.1/org.apache.lucene/lucene-core/6.2.1/a1d9ed9e06072fefa13b070628269ccc0a90d7cc/lucene-core-6.2.1.jar:/home/ash/.gradle/caches/modules-2/files-2.1/org.apache.commons/commons-lang3/3.4/5fe28b9518e58819180a43a850fbc0dd24b7c050/commons-lang3-3.4.jar:/home/ash/.gradle/caches/modules-2/files-2.1/org.apache.lucene/lucene-analyzers-common/6.2.1/8e08c604b610cdb91b898c841e8a8254b0f020dc/lucene-analyzers-common-6.2.1.jar:/home/ash/Projects/IdeaProjects/emojikeyboard-java/libs/SystemTray_v2.20_normal.jar:/usr/share/intellijidea-ce/lib/idea_rt.jar com.intellij.rt.execution.application.AppMain net.ashyon.emojikeyboard.Main
09:51:52.544 [JavaFX Application Thread] DEBUG dorkbox.systemTray.SystemTray - is JavaFX detected? true
09:51:52.549 [JavaFX Application Thread] DEBUG dorkbox.systemTray.SystemTray - is SWT detected? false
09:51:52.549 [JavaFX Application Thread] DEBUG dorkbox.systemTray.SystemTray - is using native menus? false
09:51:52.551 [JavaFX Application Thread] DEBUG dorkbox.systemTray.SystemTray - Auto-detecting tray type
09:51:52.551 [JavaFX Application Thread] DEBUG dorkbox.systemTray.SystemTray - FORCE_GTK2: true
09:51:52.599 [JavaFX Application Thread] DEBUG dorkbox.systemTray.SystemTray - GTK: gtk-x11-2.0
09:51:52.599 [JavaFX Application Thread] DEBUG dorkbox.systemTray.SystemTray - Is the system already running GTK? true
09:51:52.599 [JavaFX Application Thread] DEBUG dorkbox.systemTray.SystemTray - Loading libraries
09:51:52.630 [JavaFX Application Thread] ERROR dorkbox.systemTray.SystemTray - Auto-detected that gnome-shell is running
09:51:52.631 [JavaFX Application Thread] DEBUG dorkbox.systemTray.SystemTray - Currently using the 'gnome' desktop
09:51:52.631 [JavaFX Application Thread] DEBUG dorkbox.systemTray.SystemTray - Currently using the 'gnome' session type
09:51:52.661 [JavaFX Application Thread] DEBUG dorkbox.systemTray.SystemTray - Installing gnome-shell extension
09:51:52.682 [JavaFX Application Thread] DEBUG dorkbox.systemTray.SystemTray - Checking current version of extension for upgrade
09:51:52.683 [JavaFX Application Thread] DEBUG dorkbox.systemTray.SystemTray - DEBUG mode enabled. You need to manually restart the shell via 'gnome-shell --replace &'
09:51:52.703 [JavaFX Application Thread] DEBUG dorkbox.systemTray.SystemTray - Checking scaling factor for GTK environment, should start with 'uint32', value: 'uint32 0
'
09:51:52.963 [AWT-EventQueue-0] ERROR dorkbox.systemTray.SystemTray - Cannot initialize JavaFX
java.lang.NoSuchMethodException: javafx.application.Platform.runLater()
    at java.lang.Class.getMethod(Class.java:1786)
    at dorkbox.systemTray.util.JavaFX.dispatch(JavaFX.java:42)
    at dorkbox.systemTray.linux.jna.Gtk.dispatch(Gtk.java:310)
    at dorkbox.systemTray.swingUI._GtkStatusIconTray.<init>(_GtkStatusIconTray.java:88)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at dorkbox.systemTray.SystemTray$1.run(SystemTray.java:595)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:301)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
    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$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
    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)
09:51:52.963 [AWT-EventQueue-0] ERROR dorkbox.systemTray.SystemTray - Unable to execute JavaFX runLater(). Please create an issue with your OS and Java version so we may further investigate this issue.
09:51:52.964 [AWT-EventQueue-0] ERROR dorkbox.systemTray.SystemTray - Cannot initialize JavaFX
java.lang.NoSuchMethodException: javafx.application.Platform.runLater()
    at java.lang.Class.getMethod(Class.java:1786)
    at dorkbox.systemTray.util.JavaFX.dispatch(JavaFX.java:42)
    at dorkbox.systemTray.linux.jna.Gtk.dispatch(Gtk.java:310)
    at dorkbox.systemTray.linux.jna.Gtk.waitForStartup(Gtk.java:224)
    at dorkbox.systemTray.swingUI._GtkStatusIconTray.<init>(_GtkStatusIconTray.java:116)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at dorkbox.systemTray.SystemTray$1.run(SystemTray.java:595)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:301)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
    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$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
    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)
09:51:52.964 [AWT-EventQueue-0] ERROR dorkbox.systemTray.SystemTray - Unable to execute JavaFX runLater(). Please create an issue with your OS and Java version so we may further investigate this issue.
09:52:03.066 [AWT-EventQueue-0] ERROR dorkbox.systemTray.SystemTray - Cannot initialize JavaFX
java.lang.NoSuchMethodException: javafx.application.Platform.runLater()
    at java.lang.Class.getMethod(Class.java:1786)
    at dorkbox.systemTray.util.JavaFX.dispatch(JavaFX.java:42)
    at dorkbox.systemTray.linux.jna.Gtk.dispatch(Gtk.java:310)
    at dorkbox.systemTray.swingUI._GtkStatusIconTray.<init>(_GtkStatusIconTray.java:119)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at dorkbox.systemTray.SystemTray$1.run(SystemTray.java:595)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:301)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
    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$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
    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)
09:52:03.066 [AWT-EventQueue-0] ERROR dorkbox.systemTray.SystemTray - Unable to execute JavaFX runLater(). Please create an issue with your OS and Java version so we may further investigate this issue.
09:52:03.066 [AWT-EventQueue-0] INFO dorkbox.systemTray.SystemTray - Successfully Loaded: _GtkStatusIconTray

(java:19956): Gtk-CRITICAL **: IA__gtk_status_icon_set_from_file: assertion 'GTK_IS_STATUS_ICON (status_icon)' failed

(java:19956): Gtk-CRITICAL **: IA__gtk_status_icon_set_visible: assertion 'GTK_IS_STATUS_ICON (status_icon)' failed

2.1: [BUG] Not working on Windows

It's trying to use appindicator when on Windows:

java.lang.RuntimeException: We apologize for this, but we are unable to determine the appIndicator library is in use, if or even if it is in use... Please create an issue for this and include your OS type and configuration.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.