当前位置: 首页>>代码示例>>Java>>正文


Java TrayIcon.setToolTip方法代码示例

本文整理汇总了Java中java.awt.TrayIcon.setToolTip方法的典型用法代码示例。如果您正苦于以下问题:Java TrayIcon.setToolTip方法的具体用法?Java TrayIcon.setToolTip怎么用?Java TrayIcon.setToolTip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.TrayIcon的用法示例。


在下文中一共展示了TrayIcon.setToolTip方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setUpTrayIcon

import java.awt.TrayIcon; //导入方法依赖的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

示例2: create

import java.awt.TrayIcon; //导入方法依赖的package包/类
public static boolean create()
{
	menu = new Menu();
	try
	{
		icon = new TrayIcon(Constants.TRAY_ICON, "UploadR", menu);
		icon.addMouseListener(menu.getItemHandler());
		SystemTray.getSystemTray().add(icon);
		icon.setToolTip("UploadR");
		return true;
	}
	catch(AWTException e)
	{
		return false;
	}
}
 
开发者ID:Hual,项目名称:UploadR,代码行数:17,代码来源:MenuTrayIcon.java

示例3: 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

示例4: initSystemTray

import java.awt.TrayIcon; //导入方法依赖的package包/类
/**
 * This method inits the system tray. if supported, the program's window
 * does not deiconfy/minimize to the taskbar, but hides and displays an icon
 * in the system tray instead.
 */
private void initSystemTray() {
    // if systemtray is not supported, leave method
    if (!SystemTray.isSupported()) {
        return;
    }
    // create tray-icon with tooltip
    trayIcon = new TrayIcon((new ImageIcon(org.jdesktop.application.Application.getInstance(de.danielluedecke.zettelkasten.ZettelkastenApp.class).getClass().getResource("/de/danielluedecke/zettelkasten/resources/icons/zkn3_16x16.png"), "Zettelkasten")).getImage());
    // retrieve system tray
    tray = SystemTray.getSystemTray();
    // try to add the tray icon to the systray
    try {
        tray.add(trayIcon);
    } catch (AWTException e) {
        Constants.zknlogger.log(Level.WARNING, "Tray Icon could not be added.");
        return;
    }
    // if tray icon was successfully added, add tooltip
    trayIcon.setToolTip("Zettelkasten");
    // and mouse listener, so the window will be restored when the user clicks on the tray icon
    trayIcon.addMouseListener(new java.awt.event.MouseAdapter() {
        @Override
        public void mouseClicked(java.awt.event.MouseEvent evt) {
            // set main frame visible
            getFrame().setVisible(true);
            // restore frame state to normal state
            getFrame().setExtendedState(java.awt.Frame.NORMAL);
            // if we have a tray icon, remove it
            if (tray != null) {
                // clear popup menu
                trayIcon.setPopupMenu(null);
                // remove tray icon
                tray.remove(trayIcon);
            }
            // and say that tray icon is currently not installed
            trayIconInstalled = false;
        }
    });
    trayIconInstalled = true;
}
 
开发者ID:sjPlot,项目名称:Zettelkasten,代码行数:45,代码来源:ZettelkastenView.java

示例5: create

import java.awt.TrayIcon; //导入方法依赖的package包/类
private TrayIcon create(Image image) throws IOException {
	TrayIcon trayIcon = new java.awt.TrayIcon(image);
	trayIcon.setImageAutoSize(true);
	trayIcon.setToolTip(tooltip);
	trayIcon.setPopupMenu(createMenu(false));
	return trayIcon;
}
 
开发者ID:PeerWasp,项目名称:PeerWasp,代码行数:8,代码来源:JSystemTray.java


注:本文中的java.awt.TrayIcon.setToolTip方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。