本文整理匯總了Java中java.awt.SystemTray.getTrayIcons方法的典型用法代碼示例。如果您正苦於以下問題:Java SystemTray.getTrayIcons方法的具體用法?Java SystemTray.getTrayIcons怎麽用?Java SystemTray.getTrayIcons使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.awt.SystemTray
的用法示例。
在下文中一共展示了SystemTray.getTrayIcons方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: init
import java.awt.SystemTray; //導入方法依賴的package包/類
/**
* Initializes the tray
*/
public void init() {
if (SystemTray.isSupported()) {
SystemTray tray = SystemTray.getSystemTray();
if (tray.getTrayIcons().length == 0) {
String iconFileName = resources.getImagePath() + File.separator
+ "MidiAutomatorIcon16.png";
image = Toolkit.getDefaultToolkit().getImage(iconFileName);
trayPopupMenu.init();
trayIcon = new TrayIcon(image, NAME);
trayIcon.addMouseListener(trayMouseListener);
try {
tray.add(trayIcon);
} catch (AWTException e) {
log.error("Error on adding tray icon.", e);
}
}
}
}
示例2: setTray
import java.awt.SystemTray; //導入方法依賴的package包/類
void setTray() {
if (!Config.getInstance().getBoolean(Config.MAIN_TRAY)) {
this.removeTray();
return;
}
if (!SystemTray.isSupported()) {
LOGGER.info("tray icon not supported");
return;
}
if (mTrayIcon == null)
mTrayIcon = this.createTrayIcon();
SystemTray tray = SystemTray.getSystemTray();
if (tray.getTrayIcons().length > 0)
return;
try {
tray.add(mTrayIcon);
} catch (AWTException ex) {
LOGGER.log(Level.WARNING, "can't add tray icon", ex);
}
}
示例3: stopNotify
import java.awt.SystemTray; //導入方法依賴的package包/類
@Override
public final void stopNotify() {
if (SystemTray.isSupported() && started) {
started = false;
final SystemTray tray = SystemTray.getSystemTray();
try {
for (TrayIcon trayIcon : tray.getTrayIcons()) {
tray.remove(trayIcon);
}
tray.add(passive);
} catch (AWTException e) {
}
}
}
示例4: startNotify
import java.awt.SystemTray; //導入方法依賴的package包/類
@Override
public void startNotify(final int count, final NotifySource source, final Set<String> categories) {
if (SystemTray.isSupported() && !started) {
started = true;
final SystemTray tray = SystemTray.getSystemTray();
try {
for (TrayIcon trayIcon : tray.getTrayIcons()) {
tray.remove(trayIcon);
}
tray.add(active);
} catch (AWTException e) {
}
}
}