SWT Mac OSX - Unread Message Count (like Mac Mail or Skype) - java

I've written an SWT app, that on Windows just sits in the System Tray and changes its icon with a message count. This is fine for Windows, but when it comes to the Mac i'd like to make it look a little more native.
I can get an icon to pop itself into the doc area, which is fine, but not i'd like to get an unread message count like those found on Skype or Mac Mail. Is there a way of doing this using SWT?
Cheers

See Snippet336.java, from the SWT snippets page. TaskBar and TaskItem will do what you want. TaskItem#setOverlayText(String) will put a badge on your application's icon.

Related

Colours not enabled with JSCH

I'm trying to create a simple Vt100 emulator in Java - which work with JSCH.
Colours are displayed (when I print them with echo for example). But when I open htop, the display is set to monochromatic (and I can't change it). I've looked in HTOP source code, and it comes from a check (ncurses, has_colors): the server think that colours are not enabled on my terminal.
This is of course not a server-side problem (working well with PuTTy).
Thanks.

How to change windows desktop background

I realise that there are other questions on this topic, all of which I have attempted to implement the answers of and failed. I would like to end up with a full blown answer, ideally with a demonstration, on how to, in Windows and only Windows set the desktop background instantly without having the user log in and out or lock and log back in. The approach that involves using the runtime console to push the registry entries about and then rundll32 user32.dll call UpdatePerUserSystemPreferences has yet to work for me. The desired behaviour is achieved when the user right clicks an image file in explorer and selects 'Set as desktop background'. I'd like to do that programatically even if it devolves to the level of opening a hidden explorer window and right-clicking a file in it as long as the user sees nothing of it. The application in question updates the user's desktop background image with useful system information. The image to be used will be generated and regenerated every five seconds.
Can I change my Windows desktop wallpaper programmatically in Java/Groovy?
So the correct way is with JNA if you are not familiar with JNA or if you haven't used JNA the link above is for you. Otherwise you are right about using natives but you never stated how you are using them so I am just taking shots in the dark here.

Java command line application and Systray

I am writing Java application, which is totally GUI-less. It runs in terminal through command line and everything is fine. But now I need to add system tray's icon to it in order to provide some notifications to the user. I tried to use java.awt.SystemTray and java.awt.TrayIcon for that. Although icon almost works (leaving look and feel problem aside), my Mac OS puts new application window to the Dock, as if whole Swing application was run.
So, the question: can my GUI-less java application remain totally invisible but for the tray icon? In Mac OS, Windows and Linux.
Edit: I have tried
System.setProperty("apple.awt.UIElement", "true");
This helped me getting rid of Dock icon, but now
trayIcon.displayMessage("Run!", null, TrayIcon.MessageType.ERROR);
does not display message window.
If it doesn't work with Swing maybe you could try
SWT: Tray Icons and Tooltips.

SWT on Mac OS X: Make program reappear when user clicks on dock icon

I have an SWT application running on Mac OS X. When the user clicks on the 'close' button of the shell, I ignore the close request and just hide the shell by calling Shell.setVisible(false).
Now, how do I make my program reappear when the user clicks on the dock icon? I've tried attaching various listeners to the shell, to no avail. Couldn't find anything helpful via Google either. Thanks in advance.
Courtesy of one of the SmartGit developers (it's this message, but you need to join the group to see it) - they've logged a bug about this:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=358376

System Tray (Menu Extras) icon in Mac Os using Java

I'm developing a desktop application using Java. I want to put an icon (with a contextual menu) on the system tray (called Menu Extras in Mac Os). Java 6 comes with support for doing this in Windows and Linux, but it doesn't work in Mac Os.
I have seen some applications doing what I want in all three operating systems (e.g. DropBox), but I don't know if they are made with Java.
How can I achieve this?
If it's not possible in Java, is there any other cross-platform language able to do that?
Thanks.
AWT / Swing
According to documentation, OSX 10.5 update 1 and newer support TrayIcons
TrayIcons are represented on Mac OS X
using NSStatusMenus that are presented
to the left of the standard system
menu extras. The java.awt.Image
artwork for a TrayIcon is presented in
grayscale as per the Mac OS X standard
for menu extras.
TrayIcon.displayMessage() presents a
small non-modal dialog positioned
under the TrayIcon. The ActionListener
for the TrayIcon is only fired if the
"OK" button on the non-modal dialog is
pressed, and not if the window is
closed using the window close button.
Multiple calls to
TrayIcon.displayMessage() will dismiss
prior messages and leave only the last
message. If the application is not in
the foreground when
TrayIcon.displayMessage() is called,
the application bounces its icon in
the Dock. Message windows are badged
with the application's icon to
identify the which application
triggered the notification.
noah provided this sample:
java.awt.SystemTray.getSystemTray().add(new java.awt.TrayIcon(java.awt.Toolkit.getDefaultToolkit().getImage("foo.png")));
Note that you'll probably want to attach a menu to that icon before adding it to the tray, though.
SWT
According to documentation, SWT 3.3 and newer supports TrayItem icons on OSX.
Icons placed on the system tray will now appear when running on OS X in the status bar.
This snippet shows how to create a menu and icon and put them in the Tray.
I ported a Windows application to my Mac with little difficulty. One thing I noticed is that the icons are in full, living color (not following the Mac convention). I'll need to add a little OS-specific code to convert myself. But this is a big step up from the DLL dependent Desktop integration version from earlier iterations of Java.

Categories

Resources