Skip to main content

Able to show balloons from system tray icon?

15 replies [Last post]
troydugger
Offline
Joined: 2004-05-06

Will Mustang have the ability to show message balloons from the System Tray icon?

Thanks,
Troy

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
jwenting
Offline
Joined: 2003-12-02

> prunge,
>
> The problem is that Sun chose not to expose an API
> which allows end-users to specify whether a window
> may or may not overlap the taskbar. They simply may
> not, period.
>
which is quite normal as there are most likely JVMs running in an environment where such is prohibited (or where there is no taskbar so nothing to overlap).

> If you look at the underlying Tray API code, what Sun
> does is use reflection to get at a private variable,
> change its value and this allows that specific window
> to display on top of the taskbar.
>
Funky :)

> If Sun wants to hack its own code, great :) but we
> end-users shouldn't have to.

You don't have to, you can live long and happy without ever overlapping the taskbar (in fact I prefer it that way).

cowwoc
Offline
Joined: 2003-08-24

jwenting,

In the context of the Tray API under Windows, what you are saying makes no sense. If our goal is to match the L&F of native applications, then we *must* overlap the taskbar.

Gili

jwenting
Offline
Joined: 2003-12-02

In that case it should be a functionality of the specific L&F, not the core platform.

Which confirms my idea that an L&F should probably not be part of the core distribution (except maybe a default to be taken when no specific L&F is available on the platform or distributed with the application).

prunge
Offline
Joined: 2004-05-06

I agree that if Sun does the JPopupMenu thing they will be able to use their private variable to make the window display on top of the taskbar. Therefore it's important that this be done in mustang before everyone starts rolling their own solutions - I know I would be very tempted to do this - and since we don't have access to the private variables that Sun's code does these solutions will be less than optimal. Either native code will have to be used or we'll have to settle for a menu hidden behind a taskbar if there is no other way.

troydugger
Offline
Joined: 2004-05-06

Thanks for the info, Bino. I'm not sure a Swing version of the tray icon is needed especially if it wouldn't be able to draw the menu over the taskbar. On Windows, PopupMenu has the same look as our application since we use the default windows look and feel there. On UNIX, we might use Metal or whatever the user feels like and the PopupMenu will look Motif (at least that is what I think it looks like). UNIX users are more forgiving about lookandfeel issues, so I'm not really concerned about this. I'll let someone else enter the RFE.

One other question though... some windows applications display a dialog when the user clicks on the message balloon. Is there a way to get the MouseEvent from the balloon?

Thanks for your time.

cowwoc
Offline
Joined: 2003-08-24

I filed the necessary RFE. It has an internal review ID of 468993, please forward it to the necessary individuals.

The use-case I offered is that many native Windows applications with their own L&F (i.e. emule plus) also apply the same L&F to their tray icon popups. This sense of continuity is important. You don't want to have a gorgious looking program with a kludgy-looking popup menu.

prunge
Offline
Joined: 2004-05-06

Whoops, I also filed an RFE, it has bug ID 6285881.

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6285881

An advantage of having a JPopupMenu for the tray icon is that normal popup menus do not support things like menu icons or customized rendering.

As for the JPopupMenu being hidden by the taskbar, what if the window that contains the popup menu is made always on top by calling Window.setAlwaysOnTop(true)? If a window is set always on top it appears in front of the taskbar.

cowwoc
Offline
Joined: 2003-08-24

prunge,

The problem is that Sun chose not to expose an API which allows end-users to specify whether a window may or may not overlap the taskbar. They simply may not, period.

If you look at the underlying Tray API code, what Sun does is use reflection to get at a private variable, change its value and this allows that specific window to display on top of the taskbar.

If Sun wants to hack its own code, great :) but we end-users shouldn't have to.

cowwoc
Offline
Joined: 2003-08-24

Aparently my bug report got accepted too: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6287100

It should become visible in a couple of days. Can someone please merge my issue with prunge's?

Thanks,
Gili

bino_george
Offline
Joined: 2003-06-16

Hi Troy,

> Javadoc. It would be nice if the trayicon's menu
> could be created using Swing so that the dialogs
> shown from the menu items would have the same look
> and feel. Is that going to be possible when 1.6 is
> released?

If you have tried the JDIC version, you will remember that
we used JPopupMenu instead of PopupMenu there and the reason
you mentioned was exactly why we did it that way.
Unfortunately, a lot of people were unhappy aout some
of the quirks of JPopupMenu (such as not overlapping
the task bar). Also since the API is in AWT, we did not
want to have a dependancy on a Swing API from AWT. Typically, we do it the other way around. But
as I mentioned in the blog, if we see a lot of demand from
developers, we will provide a JTrayIcon.

If you get some time, please file an RFE for a
JTrayIcon and vote for it. This will help me justify it
to the Swing team. Thanks,

Regards,
Bino.

cowwoc
Offline
Joined: 2003-08-24

Bino,

If I understand correctly (from the blog comments) if one wants to display a JPopupMenu, one must create a new window and display the JPopupMenu manually (when a mouse click is detected). This is all nice and well, but will the JPopupMenu we manually create overlap the taskbar? If not, this is something that should be fixed ASAP. It should be possible to display JPopupMenus that overlap the taskbar without major hacking. Is this possible?

PS: When a RFE is filed, please post the bug id here. I'd like to vote for it ASAP.

Thanks,
Gili

bino_george
Offline
Joined: 2003-06-16

Hi Troy,

> Will Mustang have the ability to show message
> balloons from the System Tray icon?
>
> Thanks,
> Troy

Yes it does. All you have to do is call :
[code]
trayIcon.displayMessage("Caption", "This is an example of Notifications", type);
[/code]
Where type is one of :

TrayIcon.MessageType.ERROR - An error message
TrayIcon.MessageType.INFO - An information message
TrayIcon.MessageType.NONE - Simple message
TrayIcon.MessageType.WARNING - A warning message

Check out the javadoc :
http://www.java.net/download/jdk6/docs/api/java/awt/TrayIcon.html

You can try it out with b38 and above :

http://www.java.net/download/jdk6/binaries/

Regards,
Bino.

troydugger
Offline
Joined: 2004-05-06

thanks Bino. I'm not sure how I missed that in the Javadoc. It would be nice if the trayicon's menu could be created using Swing so that the dialogs shown from the menu items would have the same look and feel. Is that going to be possible when 1.6 is released? Thanks again.

tlund_
Offline
Joined: 2005-04-21

For info on swing support, read the comments in this blog:
http://weblogs.java.net/blog/bino_george/archive/2005/06/new_awt_feature...
:)

subanark
Offline
Joined: 2004-11-26

I really dout it.
If you want to request a feature to be part of the standard SDK, ask yourself, how can I express my request in a form that will be cross platform.

Features that only work on one platform are not for the SDK.