Currently in my (JRuby code), I want to handle "balloon close" messages differently than "double click on the tray icon" (awt.TrayIcon instance):
import java.awt.TrayIcon
import java.awt.event.MouseListener
tray = java.awt.SystemTray::system_tray
image = java.awt.Toolkit::default_toolkit.get_image('')
trayIcon = TrayIcon.new(image, 'name', nil)
tray.add(trayIcon)
trayIcon.addActionListener do |evt|
puts "in here", evt.id
end
trayIcon.displayMessage("title", "try clicking within the baloon, but not the x, then double clicking the tray icon", TrayIcon::MessageType::INFO)
puts "try clicking within the balloon message, or double clicking, both seem to generate the same event"
and the equivalent code in java https://gist.github.com/4338167
it seems that this action listener gets called either when 1) a user double clicks the icon in the system tray, or 2) a user closes a tray's recent balloon message by clicking on the balloon (not on the x).
Is it possible to distinguish between the 2 different event types (both seem to have event id 1001), or must I just infer it by timing relative or something else? Or can I somehow "know" that the balloon is still up, and thus the click must have come from it?