本文整理了Java中java.awt.TrayIcon.setImageAutoSize()
方法的一些代码示例,展示了TrayIcon.setImageAutoSize()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TrayIcon.setImageAutoSize()
方法的具体详情如下:
包路径:java.awt.TrayIcon
类名称:TrayIcon
方法名:setImageAutoSize
暂无
代码示例来源:origin: runelite/runelite
trayIcon.setImageAutoSize(true);
代码示例来源:origin: igniterealtime/Openfire
trayIcon.setImageAutoSize(true);
trayIcon.addActionListener(actionListener);
trayIcon.addMouseListener(new MouseListener() {
代码示例来源:origin: RipMeApp/ripme
trayIcon = new TrayIcon(mainIcon);
trayIcon.setToolTip(mainFrame.getTitle());
trayIcon.setImageAutoSize(true);
trayIcon.setPopupMenu(trayMenu);
SystemTray.getSystemTray().add(trayIcon);
代码示例来源:origin: stackoverflow.com
popup.add(defaultItem);
trayIcon=new TrayIcon(image, "SystemTray Demo", popup);
trayIcon.setImageAutoSize(true);
}else{
System.out.println("system tray not supported");
代码示例来源:origin: stackoverflow.com
public class Main {
static Image image = Toolkit.getDefaultToolkit().getImage("images/tray.gif");
static TrayIcon trayIcon = new TrayIcon(image, "Tester2");
public static void main(String[] a) throws Exception {
if (SystemTray.isSupported()) {
SystemTray tray = SystemTray.getSystemTray();
trayIcon.setImageAutoSize(true);
trayIcon.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("In here");
trayIcon.displayMessage("Tester!", "Some action performed", TrayIcon.MessageType.INFO);
}
});
try {
tray.add(trayIcon);
} catch (AWTException e) {
System.err.println("TrayIcon could not be added.");
}
}
}
}
代码示例来源:origin: Nilhcem/FakeSMTP
/**
* @param mainFrame The MainFrame class used for closing actions from TrayPopup.
*/
public MainWindowListener(final MainFrame mainFrame) {
useTray = (SystemTray.isSupported() && Boolean.parseBoolean(Configuration.INSTANCE.get("application.tray.use")));
if (useTray) {
final TrayPopup trayPopup = new TrayPopup(mainFrame);
final Image iconImage = Toolkit.getDefaultToolkit().getImage(getClass().
getResource(Configuration.INSTANCE.get("application.icon.path")));
trayIcon = new TrayIcon(iconImage);
trayIcon.setImageAutoSize(true);
trayIcon.setPopupMenu(trayPopup.get());
}
}
代码示例来源:origin: tomighty/tomighty
@PostConstruct
public void initialize() {
bus.subscribe(new UpdateTimeOnTray(), TimerTick.class);
bus.subscribe(new ShowTomatoIconWhenTimerStops(), TimerStopped.class);
bus.subscribe(new RemoveTimeFromTray(), TimeOnTrayConfigChanged.class);
trayIcon = new TrayIcon(icons.tomato());
trayIcon.addMouseListener(new TrayListener());
trayIcon.setImageAutoSize(true);
}
代码示例来源:origin: stackoverflow.com
trayIcon.setImageAutoSize(true);
代码示例来源:origin: i2p/i2p.i2p
/**
* Add the tray icon to the system tray and start everything up.
*/
public synchronized void startManager() throws AWTException {
if (!SystemTray.isSupported())
throw new AWTException("SystemTray not supported");
tray = SystemTray.getSystemTray();
// Windows typically has tooltips; Linux (at least Ubuntu) doesn't
String tooltip = SystemVersion.isWindows() ? _t("I2P: Right-click for menu") : null;
TrayIcon ti;
if (_useSwing)
ti = getSwingTrayIcon(tooltip);
else
ti = getAWTTrayIcon(tooltip);
ti.setImageAutoSize(true); //Resize image to fit the system tray
tray.add(ti);
trayIcon = ti;
}
代码示例来源:origin: stackoverflow.com
public static void sendNotification(String title, String subtitle, String pathToIcon) {
SystemTray mainTray = SystemTray.getSystemTray();
Image trayIconImage = Toolkit.getDefaultToolkit().getImage(pathToIcon);
TrayIcon mainTrayIcon = new TrayIcon(trayIconImage);
mainTrayIcon.setImageAutoSize(true);
try {
mainTray.add(mainTrayIcon);
mainTrayIcon.displayMessage(title, subtitle, TrayIcon.MessageType.NONE);
}
catch (Exception e) {
e.printStackTrace();
}
}
代码示例来源:origin: magefree/mage
flashedImage = ImageManagerImpl.instance.getAppFlashedImage();
trayIcon = new TrayIcon(mainImage);
trayIcon.setImageAutoSize(true);
代码示例来源:origin: Slowpoke101/FTBLaunch
public static void setUpSystemTray () {
trayMenu = new TrayMenu();
SystemTray tray = SystemTray.getSystemTray();
TrayIcon trayIcon = new TrayIcon(Toolkit.getDefaultToolkit().getImage(instance.getClass().getResource("/image/logo_ftb.png")));
trayIcon.setPopupMenu(trayMenu);
trayIcon.setToolTip(Constants.name);
trayIcon.setImageAutoSize(true);
try {
tray.add(trayIcon);
} catch (AWTException e) {
e.printStackTrace();
}
}
代码示例来源:origin: stackoverflow.com
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
public class AWTScratch {
public static void main(String[] args) {
BufferedImage im = new BufferedImage(32, 32, BufferedImage.TYPE_INT_RGB);
TrayIcon ti = new TrayIcon(im, "Multiline\nmulti");
ti.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
});
ti.setImageAutoSize(true);
if (SystemTray.isSupported()){
SystemTray st=SystemTray.getSystemTray();
try {
st.add(ti);
} catch (AWTException e1) {
e1.printStackTrace();
}
}
}
}
代码示例来源:origin: Exslims/MercuryTrade
private void createTrayIcon() {
PopupMenu trayMenu = new PopupMenu();
MenuItem exit = new MenuItem("Exit");
exit.addActionListener(e -> {
exit();
});
MenuItem restore = new MenuItem("Restore default location");
restore.addActionListener(e -> {
FramesManager.INSTANCE.restoreDefaultLocation();
});
trayMenu.add(restore);
trayMenu.add(exit);
BufferedImage icon = null;
try {
icon = ImageIO.read(getClass().getClassLoader().getResource("app/app-icon.png"));
} catch (IOException e) {
e.printStackTrace();
}
this.trayIcon = new TrayIcon(icon, "MercuryTrade", trayMenu);
this.trayIcon.setImageAutoSize(true);
SystemTray tray = SystemTray.getSystemTray();
try {
tray.add(this.trayIcon);
} catch (AWTException e) {
e.printStackTrace();
}
}
代码示例来源:origin: gurkenlabs/litiengine
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.strings().get("menu_exit"));
exitItem.addActionListener(a -> System.exit(0));
menu.add(exitItem);
trayIcon = new TrayIcon(Resources.images().get("litiengine-icon.png"), Game.info().toString(), menu);
trayIcon.setImageAutoSize(true);
try {
tray.add(trayIcon);
} catch (AWTException e) {
log.log(Level.SEVERE, e.getLocalizedMessage(), e);
}
}
}
}
代码示例来源:origin: fr.jcgay.send-notification/send-notification
@Override
public Notifier init() {
if (icon != null) {
return this;
}
if (!SystemTray.isSupported()) {
skipNotifications = true;
LOGGER.warn("SystemTray is not supported, skipping notifications...");
return this;
}
icon = new TrayIcon(createImage(application.icon().toByteArray()), application.name());
icon.setImageAutoSize(true);
try {
SystemTray.getSystemTray().add(icon);
} catch (AWTException e) {
throw new SystemTrayNotificationException("Error initializing SystemTray Icon.", e);
}
return this;
}
代码示例来源:origin: jcgay/send-notification
@Override
public Notifier init() {
if (icon != null) {
return this;
}
if (!SystemTray.isSupported()) {
skipNotifications = true;
LOGGER.warn("SystemTray is not supported, skipping notifications...");
return this;
}
icon = new TrayIcon(createImage(application.icon().toByteArray()), application.name());
icon.setImageAutoSize(true);
try {
SystemTray.getSystemTray().add(icon);
} catch (AWTException e) {
throw new SystemTrayNotificationException("Error initializing SystemTray Icon.", e);
}
return this;
}
代码示例来源:origin: stackoverflow.com
trayIcon.setImageAutoSize(true);
代码示例来源:origin: ATLauncher/ATLauncher
/**
* This tries to create the system tray menu.
*
* @throws Exception
*/
private static void trySystemTrayIntegration() throws Exception {
if (SystemTray.isSupported()) {
SystemTray tray = SystemTray.getSystemTray();
TrayIcon trayIcon = new TrayIcon(Utils.getImage("/assets/image/Icon.png"));
trayIcon.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (e.getButton() == MouseEvent.BUTTON3) {
TRAY_MENU.setInvoker(TRAY_MENU);
TRAY_MENU.setLocation(e.getX(), e.getY());
TRAY_MENU.setVisible(true);
}
}
});
trayIcon.setToolTip(Constants.LAUNCHER_NAME);
trayIcon.setImageAutoSize(true);
tray.add(trayIcon);
}
}
代码示例来源:origin: chatty/chatty
public TrayIconManager(Image image) {
if (SystemTray.isSupported()) {
tray = SystemTray.getSystemTray();
popup = new PopupMenu();
MenuItem showItem = new MenuItem("Show");
showItem.setActionCommand("show");
popup.add(showItem);
MenuItem exitItem = new MenuItem("Exit");
exitItem.setActionCommand("exit");
popup.add(exitItem);
trayIcon = new TrayIcon(image, "Chatty");
trayIcon.setImageAutoSize(true);
trayIcon.setPopupMenu(popup);
} else {
tray = null;
trayIcon = null;
popup = null;
}
}
内容来源于网络,如有侵权,请联系作者删除!