(wL) Forums

Full Version: JRuby System Tray Balloon example
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
 
Thank you! i going to add this to my Proxy Tran(gets Proxies for sites and puts them in a tester and then in to any thing your using(pK,kry,DDoS system 8) .etc)I use most for meh Runescape bots and Minecraft bots)