Cross-platform SystemTray support for Swing/AWT, GtkStatusIcon, and AppIndicator on Java 8+
Go to file
nathan c692059150 Fixed issues with loading libappindicator (for incorrect versions), now falls back to GTK. Compiled as java6. 2015-06-28 01:47:02 +02:00
.settings Updated license information. Polished release/dist process. Updated readme info 2014-11-04 11:59:26 +01:00
src/dorkbox/util/tray Fixed issues with loading libappindicator (for incorrect versions), now falls back to GTK. Compiled as java6. 2015-06-28 01:47:02 +02:00
.classpath Updated classpath 2015-02-25 13:50:34 +01:00
.gitignore Initial commit of project 2014-11-03 02:11:03 +01:00
.project Initial commit of project 2014-11-03 02:11:03 +01:00
LICENSE Updated readme to include various options. Fixed GTK tray (not appindicator). Cleaned up code. Cleaned up positioning. Added MUCH better detection of app-indicator for linux. 2015-01-23 02:53:47 +01:00
LICENSE.Apachev2 Added lantern license 2014-12-30 00:22:52 +01:00
LICENSE.MIT Changed license filenames to be lexicographical ordered 2014-11-16 15:24:50 +01:00
README.md Fixed typo in readme 2015-02-25 12:37:35 +01:00
SystemTray.iml Added intellij support. 2015-06-28 01:45:47 +02:00

README.md

SystemTray

Cross-platform SystemTray and AppIndicator support for java applications.

This libraries only purpose is to show reasonably decent system-tray icons and app-indicators with a simple popup-menu.

There are a number of problems on Linux with the Swing (and SWT) system-tray icons, namely that:

  1. Swing system-tray icons on linux do not support transparent backgrounds (they have a white background)
  2. Swing/SWT do not support app-indicators, which are necessary on more recent versions of linux
  3. Swing popup menus look like crap
    • system-tray icons use a JMenuPopup, which looks nicer than the java 'regular' one.
    • app-indicators use native popups.

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

To customize the delay (for hiding the popup) when the cursor is "moused out" of the 
   popup menu, change the value of 'SystemTrayMenuPopup.hidePopupDelay'

Not all system tray icons are the same size (default is 22px), so to properly scale the icon 
   to fit, change the value of 'SystemTray.TRAY_SIZE'
   
You might want to specify the root location of the icons used (to make it easier when
   specifying icons), change the value of 'SystemTray.ICON_PATH'
   
   
A *simple* example is as follows:
   this.systemTray = SystemTray.create("Dorkbox");

   this.systemTray.createTray("grey_icon.png");
   this.systemTray.setStatus("Not Running", "grey_icon.png");
   
   this.systemTray.addMenuEntry("Quit", new SystemTrayMenuAction() {
      @Override
      public void onClick(SystemTray systemTray) {
        systemTray.removeTray();
        // exit or something.
      }
   });
Note: This library does NOT use SWT for system-tray support, only for the purpose
      of lessening the jar dependencies. Changing it to be SWT-based is not 
      difficult, just remember that SWT on linux *already* starts up the GTK main 
      event loop.
Note: If you use the attached JNA libraries, you **MUST** load the respective
      native libraries yourself, especially with JNA (as the loading logic has
      been removed from the jar)
Note: This project was heavily influence by the excellent Lantern project,
      *Many* thanks to them for figuring out AppIndicators via JNA.
      https://github.com/getlantern/lantern