本文整理汇总了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);
}
});
}
}
示例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;
}
}
示例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");
}
}
示例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;
}
示例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;
}