当前位置: 首页>>代码示例>>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;未经允许,请勿转载。