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;
|
||||
|
||||
import java.awt.AWTException;
|
||||
import java.awt.Color;
|
||||
import java.awt.ComponentOrientation;
|
||||
import java.awt.Font;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.Image;
|
||||
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.KeyEvent;
|
||||
import java.awt.event.WindowAdapter;
|
||||
@ -37,7 +43,7 @@ import envoy.schema.User;
|
||||
* Project: <strong>envoy-client</strong><br>
|
||||
* File: <strong>ChatWindow.java</strong><br>
|
||||
* Created: <strong>28 Sep 2019</strong><br>
|
||||
*
|
||||
*
|
||||
* @author Kai S. K. Engelbart
|
||||
* @author Maximilian Käfer
|
||||
* @author Leon Hofmeister
|
||||
@ -122,13 +128,11 @@ public class ChatWindow extends JFrame {
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent e) {
|
||||
|
||||
if (e.getKeyCode() == KeyEvent.VK_ENTER && ((SettingsScreen.enterToSend && e.getModifiersEx() == 0)
|
||||
|| (e.getModifiersEx() == KeyEvent.CTRL_DOWN_MASK))) {
|
||||
|
||||
postMessage(messageList);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
// Checks for changed Message
|
||||
@ -287,7 +291,7 @@ public class ChatWindow extends JFrame {
|
||||
/**
|
||||
* Initializes the elements of the user list by downloading them from the
|
||||
* server.
|
||||
*
|
||||
*
|
||||
* @since Envoy v0.1-alpha
|
||||
*/
|
||||
private void loadUsersAndChats() {
|
||||
@ -308,7 +312,7 @@ public class ChatWindow extends JFrame {
|
||||
/**
|
||||
* Updates the data model and the UI repeatedly after a certain amount of
|
||||
* time.
|
||||
*
|
||||
*
|
||||
* @param timeout the amount of time that passes between two requests sent to
|
||||
* the server
|
||||
* @since Envoy v0.1-alpha
|
||||
@ -346,4 +350,14 @@ public class ChatWindow extends JFrame {
|
||||
* Marks messages in the current chat as {@code READ}.
|
||||
*/
|
||||
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