import java.awt.AWTException;
import java.awt.Image;
import java.awt.MenuItem;
import java.awt.PopupMenu;
import java.awt.SystemTray;
import java.awt.TrayIcon;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.IOException;
import java.util.Calendar;
import java.util.Date;
import javax.imageio.ImageIO;
object Alarm2 {
var clockImage:Image = ImageIO.read(new File("clock.png"));
var alarmImage:Image = ImageIO.read(new File("alarm.png"));;
var icon:TrayIcon = new TrayIcon(clockImage);
var alarmTime:Date = new Date();
def main(args : Array[String]){
var tray:SystemTray = SystemTray.getSystemTray();
var menu:PopupMenu = new PopupMenu();
var item:MenuItem = new MenuItem("表示");
item.addActionListener(new ActionListener() {
def actionPerformed(event:ActionEvent):Unit = {
icon.displayMessage("Alarm", "メッセージ!", TrayIcon.MessageType.INFO);
println("message was displayed.");
}
});
menu.add(item);
item = new MenuItem("終了");
item.addActionListener(new ActionListener() {
def actionPerformed(event:ActionEvent):Unit = {
System.exit(0);
}
});
menu.add(item);
icon = new TrayIcon(clockImage, "アラーム", menu);
icon.setImage(alarmImage);
tray.add(icon);
}
}
じゃじゃ馬さんを参考に。ちなみに画像も使わせて頂きました(*)。