Added Startup class and login by username.

This commit is contained in:
delvh
2019-10-12 14:45:58 +02:00
parent 18be5a957a
commit d5dd076ce2
3 changed files with 93 additions and 34 deletions

View File

@ -35,6 +35,7 @@ import envoy.schema.Users;
*
* @author Kai S. K. Engelbart
* @author Maximilian Käfer
* @author Leon Hofmeister
* @since Envoy 0.1
*/
public class ChatWindow extends JFrame {
@ -44,11 +45,13 @@ public class ChatWindow extends JFrame {
private long recipientID = 0;
private JPanel contentPane = new JPanel();
private static Client client;
private Client client;
private DefaultListModel<String> messageListModel = new DefaultListModel<>();
public ChatWindow() {
public ChatWindow(Client client) {
this.client = client;
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 600, 800);
setTitle("Envoy");
@ -212,35 +215,4 @@ public class ChatWindow extends JFrame {
+ getFirstTextContent(message) + "</span></html>");
}
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);
}
client = new Client(config);
EventQueue.invokeLater(() -> {
try {
ChatWindow frame = new ChatWindow();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
});
}
}