Oct 18 2011, 10:06 PM
Here is a little JRuby system tray example for you. It will pop up a notifier balloon from the system tray.
Code:
include Java
import java.awt.TrayIcon
import java.awt.event.MouseListener
if (java.awt.SystemTray::isSupported())
tray = java.awt.SystemTray::system_tray
image = java.awt.Toolkit::default_toolkit.get_image("tray.gif")
popup = java.awt.PopupMenu.new
exititem = java.awt.MenuItem.new("Exit")
exititem.addActionListener {java.lang.System::exit(0)}
oraitem = java.awt.MenuItem.new("Go To WL")
oraitem.addActionListener do
java.awt.Desktop::desktop.browse(java.net.URI.new("http://www.war-lords.net"))
end
popup.add(exititem)
popup.add(oraitem)
trayIcon = TrayIcon.new(image, "Tray Demo", popup)
trayIcon.image_auto_size = true
trayIcon.addMouseListener() do |method|
puts "mouse event #{method.to_s}"
end
tray.add(trayIcon)
trayIcon.displayMessage("Message","Hi!", TrayIcon::MessageType::INFO)
end
"Most people think time is like a river, that flows swift and sure in one direction. But I have seen the face of time, and I can tell you, they are wrong. Time is an ocean in a storm."