Merge pull request #53 from informatik-ag-ngl/f/background_execution

Added background execution
This commit is contained in:
Kai S. K. Engelbart 2019-12-14 14:30:19 +01:00 committed by GitHub
commit 043c166840
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 7 deletions

View File

@ -5,6 +5,7 @@ import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import envoy.client.Client;
@ -84,7 +85,7 @@ public class Startup {
throw new EnvoyException("Could not enter offline mode: user name unknown");
client.setSender(clientUser);
} catch(Exception e2) {
JOptionPane.showMessageDialog(null, e1.toString(), "Client error", JOptionPane.ERROR_MESSAGE);
JOptionPane.showMessageDialog(null, e2.toString(), "Client error", JOptionPane.ERROR_MESSAGE);
System.exit(1);
return;
}
@ -118,6 +119,9 @@ public class Startup {
try {
new StatusTrayIcon(chatWindow).show();
// If the tray icon is supported, hide the chat window on close
chatWindow.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
} catch (EnvoyException e) {
logger.warning("The StatusTrayIcon is not supported on this platform!");
}

View File

@ -75,16 +75,15 @@ public class StatusTrayIcon implements EventHandler {
focusTarget.addWindowFocusListener(new WindowAdapter() {
@Override
public void windowGainedFocus(WindowEvent e) {
displayMessages = false;
}
public void windowGainedFocus(WindowEvent e) { displayMessages = false; }
@Override
public void windowLostFocus(WindowEvent e) {
displayMessages = true;
}
public void windowLostFocus(WindowEvent e) { displayMessages = true; }
});
// Show the window if the user clicks on the icon
trayIcon.addActionListener((evt) -> { focusTarget.setVisible(true); focusTarget.requestFocus(); });
// Start processing message events
EventBus.getInstance().register(this);
}