本文整理匯總了Java中java.awt.SystemTray.isSupported方法的典型用法代碼示例。如果您正苦於以下問題:Java SystemTray.isSupported方法的具體用法?Java SystemTray.isSupported怎麽用?Java SystemTray.isSupported使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.awt.SystemTray
的用法示例。
在下文中一共展示了SystemTray.isSupported方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: initSystemTray
import java.awt.SystemTray; //導入方法依賴的package包/類
private static void initSystemTray() {
// add system tray icon with popup menu
if (SystemTray.isSupported()) {
SystemTray tray = SystemTray.getSystemTray();
PopupMenu menu = new PopupMenu();
MenuItem exitItem = new MenuItem(Resources.get("menu_exit"));
exitItem.addActionListener(a -> Game.terminate());
menu.add(exitItem);
trayIcon = new TrayIcon(RenderEngine.getImage("pixel-icon-utility.png"), Game.getInfo().toString(), menu);
trayIcon.setImageAutoSize(true);
try {
tray.add(trayIcon);
} catch (AWTException e) {
log.log(Level.SEVERE, e.getLocalizedMessage(), e);
}
}
}
示例2: processEvent
import java.awt.SystemTray; //導入方法依賴的package包/類
@Override
protected void processEvent(InboxChangeEvent event) throws IOException {
// TODO Auto-generated method stub
if (SystemTray.isSupported()) {
if(event.getUnreadItemCount() > 0) {
trayIcon.setImage(this.imageNewMail);
} else {
trayIcon.setImage(this.imageNoMail);
}
if(OwaNotifier.getInstance().getProps().getProperty("notification.type").contentEquals("system")) {
trayIcon.displayMessage(event.getEventTitle(), event.getEventText(), MessageType.INFO);
}
} else {
logger.error("System tray not supported!");
}
if(event.getUnreadItemCount() > 0) {
this.setToolTip(event.getUnreadItemCount() + " message(s) non lu");
} else {
this.setToolTip("Pas de message non lu");
}
}
示例3: addTrayIconInSystemTray
import java.awt.SystemTray; //導入方法依賴的package包/類
/** Add tray icon to system tray */
public void addTrayIconInSystemTray() {
if (SystemTray.isSupported()) {
setEventListener();
setMenu();
try {
trayIcon.setImageAutoSize(true);
trayIcon.addActionListener(showListener);
trayIcon.addMouseListener(mouseListener);
systemTray.add(trayIcon);
} catch (AWTException e) {
e.printStackTrace();
}
} else {
System.err.println("Tray unavailable");
}
}
示例4: main
import java.awt.SystemTray; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
if (!SystemTray.isSupported()) {
System.out.println("SystemTray not supported on the platform." +
" Marking the test passed.");
} else {
if (System.getProperty("os.name").toLowerCase().startsWith("win")) {
System.err.println(
"Test can fail on Windows platform\n"+
"On Windows 7, by default icon hides behind icon pool\n" +
"Due to which test might fail\n" +
"Set \"Right mouse click\" -> " +
"\"Customize notification icons\" -> \"Always show " +
"all icons and notifications on the taskbar\" true " +
"to avoid this problem.\nOR change behavior only for " +
"Java SE tray icon and rerun test.");
}
ActionEventTest test = new ActionEventTest();
test.doTest();
test.clear();
}
}
示例5: main
import java.awt.SystemTray; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
if (!SystemTray.isSupported()) {
System.out.println("SystemTray not supported on the platform "
+ "under test. Marking the test passed");
} else {
String osName = System.getProperty("os.name").toLowerCase();
if (osName.startsWith("mac")) {
isMacOS = true;
} else if (osName.startsWith("win")) {
isWinOS = true;
} else {
isOelOS = SystemTrayIconHelper.isOel7();
}
new TrayIconMouseTest().doTest();
}
}
示例6: Tray
import java.awt.SystemTray; //導入方法依賴的package包/類
public Tray(MainWindow window) {
if (tray != null)
return;
if (!SystemTray.isSupported()) {
System.err.println("係統不支持托盤!");
}
if (tray == null) {
tray = SystemTray.getSystemTray();
}
if (window == null)
throw new NullPointerException();
this.window = window;
try {
setTray();
} catch (Exception e) {
e.printStackTrace();
}
addIcon();
// window.setVisible(false);
}
示例7: setXBtnBehavior
import java.awt.SystemTray; //導入方法依賴的package包/類
public void setXBtnBehavior(boolean minimize)
{
if (!minimize)
stage.setOnCloseRequest(we -> exitRequestedByUser());
else
if (!SystemTray.isSupported())
logger.log(Level.WARNING, "Minimize to tray is not supported.");
else
{
stage.setOnCloseRequest(we ->
{
we.consume(); //ignore the application's title window exit button, instead minimize to systray
minimizeRequestCameFromXBtn = true;
performMinimizeToTray.run();
});
}
menuItemChkDisplayBalloon.setDisable(!minimize);
}
示例8: 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);
}
}
}
}
示例9: hookTray
import java.awt.SystemTray; //導入方法依賴的package包/類
private void hookTray() {
if (!SystemTray.isSupported()) {
System.out.println("SystemTray is not supported");
} else {
try {
Todo.icon = new TrayIcon(ImageIO.read(Todo.class.getResourceAsStream("/todo/res/logoTray.png")), "TODO application",
createPopupMenu());
Todo.icon.addActionListener((ActionEvent e) -> {
Platform.runLater(() -> {
stage.setIconified(false);
});
//some popup test
});
SystemTray.getSystemTray().add(Todo.icon);
//Thread.sleep(3000);
Todo.icon.displayMessage("TODO", "Listener enabled",
TrayIcon.MessageType.INFO);
} catch (AWTException | IOException ex) {
ex.printStackTrace();
}
}
}
示例10: displayMessage
import java.awt.SystemTray; //導入方法依賴的package包/類
/**
* Displays a message at the system tray
*
* @param caption
* @param text
* @param messageType
* @param listener
*/
public static void displayMessage(String caption, String text, MessageType messageType,
ActionListener listener) {
log.info(messageType + ": " + text);
if (SystemTray.isSupported()) {
removeAllListeners();
if (listener != null) {
getTrayIcon().addActionListener(listener);
}
getTrayIcon().displayMessage(caption, text, messageType);
}
}
示例11: setUpTrayIcon
import java.awt.SystemTray; //導入方法依賴的package包/類
private void setUpTrayIcon() {
if (SystemTray.isSupported()) {
//trayIcon.setImageAutoSize(true); It renders the icon very poorly.
//So we render the icon ourselves with smooth settings.
{
Dimension d = SystemTray.getSystemTray().getTrayIconSize();
trayIcon = new TrayIcon(getIconImage().getScaledInstance(d.width, d.height, Image.SCALE_SMOOTH));
}
//trayIcon = new TrayIcon(getIconImage());
//trayIcon.setImageAutoSize(true);
trayIcon.setToolTip(Translation.T().trayIconToolTip());
trayIcon.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
NULogger.getLogger().info("System tray double clicked");
setExtendedState(JFrame.NORMAL);
setVisible(true);
repaint();
SystemTray.getSystemTray().remove(trayIcon);
}
});
}
}
示例12: switchVisibility
import java.awt.SystemTray; //導入方法依賴的package包/類
private void switchVisibility() {
if (!SystemTray.isSupported()) {
return;
}
if (!Boolean.TRUE.equals(this.systrayAction.getValue())) {
return;
}
boolean v = !this.frame.isVisible();
this.frame.setVisible(v);
if (v) {
this.frame.toFront();
this.frame.setState(Frame.NORMAL);
}
if (!v) {
try {
SystemTray.getSystemTray().add(this.trayIcon);
} catch (AWTException ex) {
HqlBuilderFrame.logger.error("{}", ex);
}
} else {
SystemTray.getSystemTray().remove(this.trayIcon);
}
}
示例13: IconeTaches
import java.awt.SystemTray; //導入方法依賴的package包/類
private IconeTaches() {
super(Images.get("divers/icone.png", true), TITRE);
setImageAutoSize(true);
setPopupMenu(menu = new PopupMenu("Menu"));
menu.add(quitter = new MenuItem("Quitter"));
menu.add(infos = new MenuItem("A propos..."));
menu.add(admin = new MenuItem("Administrer"));
menu.addSeparator();
menu.add(d3d = new MenuItem("Dessin 3D"));
menu.add(d2d = new MenuItem("Dessin 2D"));
quitter.addActionListener(this);
infos.addActionListener(this);
admin.addActionListener(this);
d3d.addActionListener(this);
d2d.addActionListener(this);
if(SystemTray.isSupported()) try {
SystemTray.getSystemTray().add(this);
} catch(AWTException e) {
e.printStackTrace();
}
}
示例14: addToTray
import java.awt.SystemTray; //導入方法依賴的package包/類
/**
* Fügt dieses WollMuxBarTrayIcon zur SystemTray hinzu (sofern die SystemTray auf
* dem aktuellen System supportet ist).
*
* @throws UnavailableException
* wenn die SystemTray nicht verfügbar ist.
*
* @author Daniel Benkmann (D-III-ITD-D101)
*/
public void addToTray() throws UnavailableException
{
if (!SystemTray.isSupported())
{
throw new UnavailableException(L.m("System Tray ist nicht verfügbar!"));
}
SystemTray tray = SystemTray.getSystemTray();
try
{
tray.add(icon);
}
catch (AWTException e)
{
throw new UnavailableException(L.m("System Tray ist nicht verfügbar!"), e);
}
}
示例15: setUpSysTray
import java.awt.SystemTray; //導入方法依賴的package包/類
private void setUpSysTray() {
if(!SystemTray.isSupported()) {
JOptionPane.showMessageDialog(this,
"Your OS doesn't support sytem tray.\n" +
"Lector will execute without a tray icon.",
Lector.APP_NAME,
JOptionPane.WARNING_MESSAGE);
return;
}
SystemTray tray = SystemTray.getSystemTray();
LectorTrayIcon trayIcon = new LectorTrayIcon();
try {
tray.add(trayIcon);
} catch (AWTException e) {
e.printStackTrace();
}
}