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


Java TrayIcon.setImageAutoSize方法代碼示例

本文整理匯總了Java中java.awt.TrayIcon.setImageAutoSize方法的典型用法代碼示例。如果您正苦於以下問題:Java TrayIcon.setImageAutoSize方法的具體用法?Java TrayIcon.setImageAutoSize怎麽用?Java TrayIcon.setImageAutoSize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.awt.TrayIcon的用法示例。


在下文中一共展示了TrayIcon.setImageAutoSize方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: initSystemTray

import java.awt.TrayIcon; //導入方法依賴的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: initUI

import java.awt.TrayIcon; //導入方法依賴的package包/類
/**
 * Init Swing UI
 */
private void initUI() {
	URL url = null;
	if (ConfigIO.getInstance().isUseDarkIcon()) {
		url = Dropzone.class.getResource("/images/sds_logo_dark.png");
	} else {
		url = Dropzone.class.getResource("/images/sds_logo_light.png");

	}
	if (Util.getOSType() == OSType.MACOS) {

	}

	trayIcon = new TrayIcon(Toolkit.getDefaultToolkit().getImage(url), I18n.get("tray.appname"),
			new TrayPopupMenu());
	trayIcon.setImageAutoSize(true);

	final SystemTray tray = SystemTray.getSystemTray();
	try {
		tray.add(trayIcon);
	} catch (AWTException e) {
		LOG.error("TrayIcon could not be added.");
		System.exit(1);
	}
}
 
開發者ID:michaelnetter,項目名稱:dracoon-dropzone,代碼行數:28,代碼來源:Dropzone.java

示例3: startTray

import java.awt.TrayIcon; //導入方法依賴的package包/類
private static void startTray()
{
	SystemTray tray = SystemTray.getSystemTray();
	int w = 80;
	int[] pix = new int[w * w];
	for (int i = 0; i < w * w; i++)
		pix[i] = (int) (Math.random() * 255);
	ImageProducer producer = new MemoryImageSource(w, w, pix, 0, w);
	Image image = Toolkit.getDefaultToolkit().createImage(producer);
	TrayIcon trayIcon = new TrayIcon(image);
	trayIcon.setImageAutoSize(true);
	startWindow();
	try
	{
		tray.add(trayIcon);
		System.out.println("installed tray");
	}
	catch (AWTException e)
	{
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
}
 
開發者ID:yajsw,項目名稱:yajsw,代碼行數:24,代碼來源:HelloWorld.java

示例4: initTray

import java.awt.TrayIcon; //導入方法依賴的package包/類
private void initTray() {
	final SystemTray systemTray = SystemTray.getSystemTray();
	final TrayIcon trayIcon = new TrayIcon(getImage("icon.gif"), "Deskshare is running");
	trayIcon.setImageAutoSize(true); // Autosize icon base on space
									 // available on tray
	MouseAdapter mouseAdapter = new MouseAdapter() {
		@Override
		public void mouseClicked(MouseEvent evt) {
			// This will display small popup message from System Tray
			trayIcon.displayMessage("BigMarker Deskshare", "This is an info message", TrayIcon.MessageType.INFO);
			if (!app.isVisible()) {
				app.setVisible(true);
			}
		}
	};
	trayIcon.addMouseListener(mouseAdapter);
	try {
		systemTray.add(trayIcon);
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
開發者ID:BigMarker,項目名稱:deskshare-public,代碼行數:23,代碼來源:SmallUI.java

示例5: initTray

import java.awt.TrayIcon; //導入方法依賴的package包/類
private void initTray() {
	final SystemTray systemTray = SystemTray.getSystemTray();
	final TrayIcon trayIcon = new TrayIcon(getImage("icon.gif"), "Deskshare is running");
	trayIcon.setImageAutoSize(true); // Autosize icon base on space available on tray
	MouseAdapter mouseAdapter = new MouseAdapter() {
		@Override
		public void mouseClicked(MouseEvent evt) {
			System.out.println("icon clicked: " + evt.getClickCount());
			// This will display small popup message from System Tray
			trayIcon.displayMessage("BigMarker Deskshare", "This is an info message", TrayIcon.MessageType.INFO);
			if (!app.isVisible()) {
				app.setVisible(true);
			}
		}
	};
	trayIcon.addMouseListener(mouseAdapter);
	try {
		systemTray.add(trayIcon);
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
開發者ID:BigMarker,項目名稱:deskshare-public,代碼行數:23,代碼來源:DebugUI.java

示例6: createComponents

import java.awt.TrayIcon; //導入方法依賴的package包/類
private void createComponents() {
    PopupMenu menu = new PopupMenu();
    menu.add(createMenuItem(openAction));
    menu.add(createMenuItem(controlPanelAction));
    menu.addSeparator();
    menu.add(createMenuItem(quitAction));

    URL url = getClass().getResource("/images/futuresonic-21.png");
    Image image = Toolkit.getDefaultToolkit().createImage(url);
    TrayIcon trayIcon = new TrayIcon(image, "FutureSonic Music Streamer", menu);
    trayIcon.setImageAutoSize(false);

    try {
        SystemTray.getSystemTray().add(trayIcon);
    } catch (Throwable x) {
        System.err.println("Failed to add tray icon.");
    }
}
 
開發者ID:FutureSonic,項目名稱:FutureSonic-Server,代碼行數:19,代碼來源:SubsonicController.java

示例7: createComponents

import java.awt.TrayIcon; //導入方法依賴的package包/類
private void createComponents() {
    PopupMenu menu = new PopupMenu();
    menu.add(createMenuItem(openAction));
    menu.add(createMenuItem(controlPanelAction));
    menu.addSeparator();
    menu.add(createMenuItem(quitAction));

    URL url = getClass().getResource("/images/madsonic-21.png");
    Image image = Toolkit.getDefaultToolkit().createImage(url);
    TrayIcon trayIcon = new TrayIcon(image, "Madsonic Music Streamer", menu);
    trayIcon.setImageAutoSize(false);

    try {
        SystemTray.getSystemTray().add(trayIcon);
    } catch (Throwable x) {
        System.err.println("Failed to add tray icon.");
    }
}
 
開發者ID:MadMarty,項目名稱:madsonic-server-5.1,代碼行數:19,代碼來源:MadsonicController.java

示例8: SysTrayIcon

import java.awt.TrayIcon; //導入方法依賴的package包/類
public SysTrayIcon(JDesktopAgent frame, String tooltip) {
    Translate translate = Translate.getTranslate();
    if (SystemTray.isSupported()) {
        Image image = Toolkit.getDefaultToolkit().getImage("icon.png");

        PopupMenu popup = new PopupMenu();
        popup.add(new RestoreMenuItem(frame, translate.backgroundRestore()));
        popup.addSeparator();
        popup.add(new AboutMenuItem(translate.about()));
        popup.addSeparator();
        popup.add(new ExitMenuItem(translate.exit()));

        TrayIcon trayIcon = new TrayIcon(image, tooltip, popup);
        trayIcon.setImageAutoSize(true);
        trayIcon.addMouseListener(new IconListener(frame));

        try {
            SystemTray.getSystemTray().add(trayIcon);
        } catch (AWTException e) {
            new SysTrayForm(frame).setVisible(true);
        }
    } else {
        new SysTrayForm(frame).setVisible(true);
    }

}
 
開發者ID:gems-uff,項目名稱:oceano,代碼行數:27,代碼來源:SysTrayIcon.java

示例9: buildTrayIcon

import java.awt.TrayIcon; //導入方法依賴的package包/類
public TrayIcon buildTrayIcon() throws IOException {
    PopupMenu popup = new PopupMenu();
    for (MenuItemDefinition mid : menuItems) {
        if (mid instanceof SeperatorMenuItem) {
            popup.addSeparator();
        } else {
            MenuItem item = new MenuItem();
            item.setLabel(mid.getText());
            item.addActionListener(mid);
            popup.add(item);
        }
    }

    TrayIcon ti = new TrayIcon(getImage(imageName), tooltip, popup);
    ti.setImageAutoSize(true);
    return ti;
}
 
開發者ID:devbury,項目名稱:mkRemote,代碼行數:18,代碼來源:TrayIconDefinition.java

示例10: MyBot

import java.awt.TrayIcon; //導入方法依賴的package包/類
public MyBot(String UserName, String Password, String URL) throws Exception{

	        this.setName(UserName);
	        this.setEncoding("UTF-8");
            this.connect(URL, 6667, Password);
            this.joinChannel("#"+UserName);

			sapi.setVoice("Zira");
			sapi.setSpeed(0);
            
            tray  = SystemTray.getSystemTray();
    		icon = new TrayIcon(ImageIO.read(new File("./icon.png")), "Twitch Bouyomi");
    		icon.setImageAutoSize(true);
    		tray.add(icon);
    		
    		BufferedReader reader = new BufferedReader(new FileReader("Replacement_JP.dic"));
    		String rl;
    		while((rl = reader.readLine()) != null) {
    			if(!(rl.startsWith("//") || rl.equals(""))){
    				repDicJP.put(rl.split(",")[0],rl.split(",")[1]);
    			}
    		}
    		reader.close();
    		
    		BufferedReader reader2 = new BufferedReader(new FileReader("BlockUsers.txt"));
    		String rl2;
    		for(int i=0;(rl2 = reader2.readLine()) != null; i++) {
    			if(i==1000) break;
    			blockUsers[i] = rl2;
    		}
    		reader2.close();
    		
    		BufferedReader reader3 = new BufferedReader(new FileReader("Replacement_EN.dic"));
    		String rl3;
    		while((rl3 = reader3.readLine()) != null) {
    			if(!(rl3.startsWith("//") || rl3.equals(""))){
    				repDicEN.put(rl3.split(",")[0],rl3.split(",")[1]);
    			}
    		}
    		reader3.close();
	}
 
開發者ID:advancedbear,項目名稱:TwitchBouyomi,代碼行數:42,代碼來源:MyBot.java

示例11: start

import java.awt.TrayIcon; //導入方法依賴的package包/類
private void start(String[] args) {
    SystemTray tray = SystemTray.getSystemTray();
    TrayIcon icon = new TrayIcon(Toolkit.getDefaultToolkit().createImage(
            getClass().getResource(
                    "/com/ramussoft/gui/server/application.png")),
            getString("Server") + " " + Metadata.getApplicationName(),
            createPopupMenu());
    icon.setImageAutoSize(true);
    try {
        tray.add(icon);
    } catch (AWTException e) {
        e.printStackTrace();
    }
}
 
開發者ID:Vitaliy-Yakovchuk,項目名稱:ramus,代碼行數:15,代碼來源:Manager.java

示例12: createSystemTrayIcons

import java.awt.TrayIcon; //導入方法依賴的package包/類
private void createSystemTrayIcons() {

        final TrayIcon trayIcon = new TrayIcon(createSystemTrayIconImage());
        trayIcon.setImageAutoSize(true);
        trayIcon.setToolTip("Update Popup Menu items");

        try {
            trayIcon.setPopupMenu(createPopupMenu(trayIcon, 2));
            SystemTray.getSystemTray().add(trayIcon);

        } catch (AWTException ex) {
            throw new RuntimeException("System Tray cration failed");
        }
    }
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:15,代碼來源:UpdatePopupMenu.java

示例13: createSystemTrayIcon

import java.awt.TrayIcon; //導入方法依賴的package包/類
private static void createSystemTrayIcon() {
    final TrayIcon trayIcon = new TrayIcon(createTrayIconImage());
    trayIcon.setImageAutoSize(true);

    try {
        // Add tray icon to system tray *before* adding popup menu to demonstrate buggy behaviour
        trayIcon.setPopupMenu(createTrayIconPopupMenu());
        SystemTray.getSystemTray().add(trayIcon);
        iconWeakReference.set(new WeakReference<>(trayIcon));
        popupWeakReference.set(new WeakReference<>(trayIcon.getPopupMenu()));
    } catch (final AWTException awte) {
        awte.printStackTrace();
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:15,代碼來源:PopupMenuLeakTest.java

示例14: TrayApplication

import java.awt.TrayIcon; //導入方法依賴的package包/類
public TrayApplication(String args[])
{
    if (!SystemTray.isSupported())
    {
        log.severe("\bTrayIcon is not supported, unable to run Scorekeeper monitor application.");
        System.exit(-1);
    }

    if (!ensureSingleton())
    {
        log.warning("Another TrayApplication is running, quitting now.");
        System.exit(-1);
    }

    actions = new Actions();
    state = new StateControl();
    statuswindow = new ScorekeeperStatusWindow(actions);

    PopupMenu trayPopup = new PopupMenu();
    trayPopup.add(new WrappedAWTMenuItem(actions.openStatus));
    trayPopup.addSeparator();
    for (Action a : actions.apps)
        trayPopup.add(new WrappedAWTMenuItem(a));
    trayPopup.addSeparator();
    trayPopup.add(new WrappedAWTMenuItem(actions.quit));

    trayIcon = new TrayIcon(conewarn, "Scorekeeper Monitor", trayPopup);
    trayIcon.setImageAutoSize(true);

    Messenger.register(MT.BACKEND_READY, (type, data) -> trayIcon.setImage(((boolean)data) ? coneok : conewarn));

    try {
        SystemTray.getSystemTray().add(trayIcon);
    } catch (AWTException e) {
        log.severe("\bFailed to create TrayIcon: " + e);
        System.exit(-2);
    }

    statuswindow.setVisible(true);
}
 
開發者ID:drytoastman,項目名稱:scorekeeperfrontend,代碼行數:41,代碼來源:TrayApplication.java

示例15: setupTrayIcon

import java.awt.TrayIcon; //導入方法依賴的package包/類
private TrayIcon setupTrayIcon()
{
	if (!SystemTray.isSupported())
	{
		return null;
	}

	SystemTray systemTray = SystemTray.getSystemTray();
	TrayIcon trayIcon = new TrayIcon(ICON, properties.getTitle());
	trayIcon.setImageAutoSize(true);

	try
	{
		systemTray.add(trayIcon);
	}
	catch (AWTException ex)
	{
		log.debug("Unable to add system tray icon", ex);
		return trayIcon;
	}

	// bring to front when tray icon is clicked
	trayIcon.addMouseListener(new MouseAdapter()
	{
		@Override
		public void mouseClicked(MouseEvent e)
		{
			setVisible(true);
			setState(Frame.NORMAL); // unminimize
		}
	});

	return trayIcon;
}
 
開發者ID:runelite,項目名稱:runelite,代碼行數:35,代碼來源:ClientUI.java


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