
Aside from the files ChatWindow, Client and SettingsScreen, theirs is already in my commit in f/settings
61 lines
1.5 KiB
Java
61 lines
1.5 KiB
Java
package envoy.client.ui;
|
|
|
|
import java.awt.EventQueue;
|
|
import java.io.IOException;
|
|
import java.util.Properties;
|
|
|
|
import javax.swing.JOptionPane;
|
|
|
|
import envoy.client.Client;
|
|
import envoy.client.Config;
|
|
|
|
/**
|
|
* Starts the Envoy client and prompts the user to enter their name.
|
|
*
|
|
* Project: <strong>envoy-client</strong><br>
|
|
* File: <strong>Startup.java</strong><br>
|
|
* Created: <strong>12 Oct 2019</strong><br>
|
|
*
|
|
* @author Leon Hofmeister
|
|
* @author Maximilian Käfer
|
|
* @since Envoy v0.1-alpha
|
|
*/
|
|
public class Startup {
|
|
|
|
public static void main(String[] args) {
|
|
Config config = new Config();
|
|
if (args.length > 0) {
|
|
config.load(args);
|
|
} else {
|
|
ClassLoader loader = Thread.currentThread().getContextClassLoader();
|
|
try {
|
|
Properties configProperties = new Properties();
|
|
configProperties.load(loader.getResourceAsStream("server.properties"));
|
|
config.load(configProperties);
|
|
} catch (IOException e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
if (!config.isInitialized()) {
|
|
System.err.println("Server or port are not defined. Exiting...");
|
|
System.exit(1);
|
|
}
|
|
|
|
String userName = JOptionPane.showInputDialog("Please enter your username");
|
|
if (userName == null || userName.isEmpty()) {
|
|
System.err.println("User name is not set or empty. Exiting...");
|
|
System.exit(1);
|
|
}
|
|
Client client = new Client(config, userName);
|
|
|
|
EventQueue.invokeLater(() -> {
|
|
try {
|
|
ChatWindow frame = new ChatWindow(client);
|
|
frame.setVisible(true);
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
});
|
|
}
|
|
} |