【发布时间】:2021-02-15 04:01:22
【问题描述】:
Java 类 TrayIcon,通知消息。如何用自定义声音替换系统声音? 也许我需要静音系统声音并播放我的?有什么 exec 命令可以做到这一点吗?
更新:Windows 托盘上工作通知的重要组成部分
public void notifyIt() {
if (SystemTray.isSupported()) {
try {
mPromptClock.displayTray();
} catch (AWTException e) {
e.printStackTrace();
}
} else {
System.err.println("System tray not supported!");
}
}
private void displayTray() throws AWTException {
SystemTray tray = SystemTray.getSystemTray();
File f = new File("./src/res/0.jpg");
BufferedImage image = null;
try {
image = ImageIO.read(f);
} catch (IOException e) {
e.printStackTrace();
}
TrayIcon trayIcon = new TrayIcon(image, "Vaqt bo'ldi");
trayIcon.setImageAutoSize(true);
trayIcon.setToolTip("1st message");
tray.add(trayIcon);
trayIcon.displayMessage("2nd message"+navbat, "Vaqtingiz bo'ldi", TrayIcon.MessageType.INFO);//Navbat
}
【问题讨论】:
-
嘿,那些超级 puper java 开发者在哪里 :( 。我无法在我的应用程序中替换 TrayIcon,因为它不会在打字时干扰。
标签: java windows swing audio desktop