try {
mSystemTray = java.awt.SystemTray.getSystemTray();
boolean isSupported = java.awt.SystemTray.isSupported();
if(isSupported) {
try {
if(new File("imgs/TrayIcon.png").isFile()) {
mTrayIcon = new TrayIcon(ImageIO.read(new File("imgs/TrayIcon.png")), tooltip);
}
else {
Dimension trayIconSize = getTrayIconSize();
BufferedImage trayIconImage = null;
Color backgroundColor = null;
if(trayIconSize.height > 16 && trayIconSize.height <= 32 && new File("imgs/tvbrowser32.png").isFile()) {
trayIconImage = UiUtilities.scaleIconToBufferedImage(ImageIO.read(new File("imgs/tvbrowser32.png")),
trayIconSize.width, trayIconSize.height, BufferedImage.TYPE_INT_ARGB, backgroundColor);
}
else if(trayIconSize.height > 32 && trayIconSize.height <= 48 && new File("imgs/tvbrowser48.png").isFile()) {
trayIconImage = UiUtilities.scaleIconToBufferedImage(ImageIO.read(new File("imgs/tvbrowser48.png")),
trayIconSize.width, trayIconSize.height, BufferedImage.TYPE_INT_ARGB, backgroundColor);
}
else if(trayIconSize.height > 48 && new File("imgs/tvbrowser128.png").isFile()) {
trayIconImage = UiUtilities.scaleIconToBufferedImage(ImageIO.read(new File("imgs/tvbrowser128.png")),
trayIconSize.width, trayIconSize.height, BufferedImage.TYPE_INT_ARGB, backgroundColor);
}
else {
trayIconImage = ImageIO.read(new File("imgs/tvbrowser16.png"));
}
mTrayIcon = new TrayIcon(trayIconImage, tooltip);
}
}catch(Throwable sizeFault) {
mTrayIcon = new TrayIcon(ImageIO.read(new File("imgs/tvbrowser16.png")), tooltip);
}
mTrayParent = new JDialog();
mTrayParent.setTitle("Tray-Menu");