當前位置: 首頁>>代碼示例>>Java>>正文


Java SystemTray.isSupported方法代碼示例

本文整理匯總了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);
    }
  }
}
 
開發者ID:gurkenlabs,項目名稱:litiengine,代碼行數:19,代碼來源:Program.java

示例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");
	}
}
 
開發者ID:OwaNotifier,項目名稱:owa-notifier,代碼行數:23,代碼來源:SystemDesktopProxy.java

示例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");
	}
}
 
開發者ID:Team-Sprout,項目名稱:Clipcon-Client,代碼行數:20,代碼來源:TrayIconManager.java

示例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();
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:23,代碼來源:ActionEventTest.java

示例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();
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:17,代碼來源:TrayIconMouseTest.java

示例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);
}
 
開發者ID:hafrans,項目名稱:Dannmaku-hime,代碼行數:22,代碼來源:Tray.java

示例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);
}
 
開發者ID:ck3ck3,項目名稱:WhoWhatWhere,代碼行數:20,代碼來源:GUIController.java

示例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);
			}
		}
	}
}
 
開發者ID:aguelle,項目名稱:MIDI-Automator,代碼行數:27,代碼來源:Tray.java

示例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();
        }

    }
}
 
開發者ID:TomasBisciak,項目名稱:TodoLazyList,代碼行數:25,代碼來源:Tray.java

示例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);
  }
}
 
開發者ID:brunocvcunha,項目名稱:taskerbox,代碼行數:24,代碼來源:TaskerboxTrayUtils.java

示例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);
            }
        });
    }
}
 
開發者ID:Neembuu-Uploader,項目名稱:neembuu-uploader,代碼行數:26,代碼來源:NeembuuUploader.java

示例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);
    }
}
 
開發者ID:jurgendl,項目名稱:hql-builder,代碼行數:24,代碼來源:HqlBuilderFrame.java

示例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();
	}
}
 
開發者ID:adeprez,項目名稱:Sources-Jeu,代碼行數:22,代碼來源:IconeTaches.java

示例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);
  }
}
 
開發者ID:WollMux,項目名稱:WollMux,代碼行數:26,代碼來源:WollMuxBarTrayIcon.java

示例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();
	}
}
 
開發者ID:Nirei,項目名稱:lector-rvsp,代碼行數:20,代碼來源:LectorWindow.java


注:本文中的java.awt.SystemTray.isSupported方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。