Ubuntu has desktop notifications at the bottom of the screen. My question is how to use it with Java. I couldn't find a solution for this. I use Gnome-shell, but does it work on the same way with Unity? And has Debian also the same notification system? And if you know the answer, I hope you will give an example so I'll understand it better.
The SystemTray and TrayIcon should do what you need. If not, maybe Twinkle will:
Twinkle lets you create desktop notifications from your Java Swing
application with ease!
Read the section from the Swing tutorial on How to Use The System Tray for a working example.
Related
In Java I'm writing a System Tray application which runs in the background on a user's desktop.
How does one interact/interop with this system tray app from another Java program? I want to be able to send notifications to the service arbitrarily, eg causing it to then show a balloon message.
Any solution needs to work on Windows and Mac, and it would be nice if it worked on Linux too - but hey, Java is inherently cross-platform so this shouldn't be an issue.. right?!
Many thanks
If the other (non-tray) programs are Java, RMI is probably the easiest approach. If the other programs aren't Java, but have good support for SOAP, create a WSDL (including XML schema) to represent the notification message(s), and have the tray app call Endpoint.create to listen for SOAP messages from other programs.
When a help topic is clicked on an OSX app's Help menu the so-called Help Viewer loads with the relevant page shown.
How can this be achieved by a Java Swing app?
Traditionally like this:
Application.getApplication().openHelpViewer();
where Application is in com.apple.eawt. To make it work properly the whole application will have to be jarred up and embedded appropriately in an .app structure with the help documents in the right place. The Jarbundler ant task will do this for you.
I want to make a GUI application for Ubuntu written in Clojure (so using Java GUI libraries). I know how to write Swing apps, to run as 'normal' GUI apps. I want to do something a little different and am not sure how to approach it; I want to write a program to run in the sys tray, and every X minutes remind me something in a small window that shows near the sys tray.
Thanks for the help,
Alex
If you are targeting java 6 you can use,
http://java.sun.com/developer/technicalArticles/J2SE/Desktop/javase6/systemtray/
works cross platform.
You might want to look at Brian Carpers clj-qt4-mailtray
It uses Qt so should run cross platform as an added bonus. Brian has an explanatory article here.
I am trying to make a contribution to the windows task bar so when i minimize my app it docks itself into the windows task bar , the best way of describing this is by looking at a picture I have drawn:
If anybody knows if this is possible or how to do it please let me know.
I am well aware of the ability to add an icon to the system tray - but this is slightly different.
Thanks in advance,
Andy
You should probably have to use JNI or JNA to achieve this - wrapping the native windows API seems like the most viable idea. It'll greatly diminish the value of using Java, however - using JNI/JNA should always be considered last resort...
Take a look at SWT. This will definitely be a platform specific solution but I am assuming this isn't an issue for you.
SWT (Beginning with 3.6 which just went gold) has a TaskBar class and corresponding TaskItem classes for each item in the TaskBar. I don't think the TaskItem class is going to be powerful enough to do what you are asking for, but by looking at the source it will provide you insight into the low level Windows calls that you can access to get this done.
The SWT version for Windows will have a low level platform specific API that should get you where you want to go. Basically they have done all the JNA/JNI work for you. I am not a Windows programmer so I can't give you more details, but hopefully this will point you in the right direction.
You just need to use the System Tray functionality available in Java 6.
If you look at the More Information section at the bottom of that page it has links to the System Tray API and an example project.
Could you hide your application on minimize and then add an icon for it to the system tray that, when clicked, unhides your application?
This is my first post on Stack Overflow and I'm just wondering on the options of making a system tray application. The application would run primary from the system tray while still operating, and could be brought up into a window when clicked on. It is also needed to have some support for global keystroke tracking, to bring up a window.
I'm curious on what options I have available to me, as I'm sure that there are many ways to do this. I'm most familiar with with Java though I have some experience with C++. I'm willing to explore other languages if they have some definite perks to them, though it would be nice to work with what I know in a way.
Thank you
Java 6 has new functionality which allows for the creation of applications which use the system tray.
The New System Tray Functionality in Java SE 6 article goes into the details, and provides some sample code as well.
The newly added SystemTray and TrayIcon classes of the java.awt package can be used to add icons to the system tray. The icons can respond to mouse clicks and use pop up menus as well. However, this new functionality is a part of AWT, so it doesn't do a very good job integrating with Swing components.
Here's an example of a little clock that shows up in the system tray which was made using the SystemTray and TrayIcon classes in Java 6:
(source: coobird.net)
Plain old Winforms would get my vote.
If you are familiar with Java you should have little difficulty using one of the managed languages to create a simple tray app with .NET.
Here is some advice on the correct way to create a tray app.
Be carefully with manged applications and Java here. Tray applications run all the time. So, if they are poorly written then they can use enough system resources to interfere with other things.
There is nothing wrong with manged code or Java in general, but it can be more difficult to keep managed or java apps frugal with memory, I/O and CPU time.
I'm saying this as a dev manger on the Windows perf team - we've seen lots and lots of very piggy tray applications. Yes, some are even windows or MSFT applications.
It may be a better approach to write a very small light weight tray app that launches a richer process when the user needs it. You can write your try app in simple C++ right on top of the low level Win32 APIs. If you don't want to use the Win32 APIs directly, you can use the Windows Template Library.