Added a test call to the system tray displaying a message
This commit is contained in:
parent
c22e9923ea
commit
06bd127432
@ -1,11 +1,17 @@
|
|||||||
package envoy.client.ui;
|
package envoy.client.ui;
|
||||||
|
|
||||||
|
import java.awt.AWTException;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.ComponentOrientation;
|
import java.awt.ComponentOrientation;
|
||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
import java.awt.GridBagConstraints;
|
import java.awt.GridBagConstraints;
|
||||||
import java.awt.GridBagLayout;
|
import java.awt.GridBagLayout;
|
||||||
|
import java.awt.Image;
|
||||||
import java.awt.Insets;
|
import java.awt.Insets;
|
||||||
|
import java.awt.SystemTray;
|
||||||
|
import java.awt.Toolkit;
|
||||||
|
import java.awt.TrayIcon;
|
||||||
|
import java.awt.TrayIcon.MessageType;
|
||||||
import java.awt.event.KeyAdapter;
|
import java.awt.event.KeyAdapter;
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
import java.awt.event.WindowAdapter;
|
import java.awt.event.WindowAdapter;
|
||||||
@ -122,13 +128,11 @@ public class ChatWindow extends JFrame {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void keyReleased(KeyEvent e) {
|
public void keyReleased(KeyEvent e) {
|
||||||
|
|
||||||
if (e.getKeyCode() == KeyEvent.VK_ENTER && ((SettingsScreen.enterToSend && e.getModifiersEx() == 0)
|
if (e.getKeyCode() == KeyEvent.VK_ENTER && ((SettingsScreen.enterToSend && e.getModifiersEx() == 0)
|
||||||
|| (e.getModifiersEx() == KeyEvent.CTRL_DOWN_MASK))) {
|
|| (e.getModifiersEx() == KeyEvent.CTRL_DOWN_MASK))) {
|
||||||
|
|
||||||
postMessage(messageList);
|
postMessage(messageList);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// Checks for changed Message
|
// Checks for changed Message
|
||||||
@ -346,4 +350,14 @@ public class ChatWindow extends JFrame {
|
|||||||
* Marks messages in the current chat as {@code READ}.
|
* Marks messages in the current chat as {@code READ}.
|
||||||
*/
|
*/
|
||||||
private void readCurrentChat() { if (currentChat != null) { localDB.setMessagesToRead(currentChat); } }
|
private void readCurrentChat() { if (currentChat != null) { localDB.setMessagesToRead(currentChat); } }
|
||||||
|
|
||||||
|
private void displayNotification(String message) throws AWTException {
|
||||||
|
SystemTray tray = SystemTray.getSystemTray();
|
||||||
|
Image image = Toolkit.getDefaultToolkit().createImage(getClass().getResource("Envoy Logo.png"));
|
||||||
|
TrayIcon trayIcon = new TrayIcon(image, "Envoy Client");
|
||||||
|
trayIcon.setImageAutoSize(true);
|
||||||
|
trayIcon.setToolTip("You are notified if you have unread messages.");
|
||||||
|
tray.add(trayIcon);
|
||||||
|
trayIcon.displayMessage("Envoy Client", message, MessageType.INFO);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
BIN
src/main/resources/Envoy Logo.png
Normal file
BIN
src/main/resources/Envoy Logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.0 KiB |
Reference in New Issue
Block a user