Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package fr.crafttim.chat.client;
- import java.awt.Dimension;
- import javax.swing.JFrame;
- import javax.swing.UIManager;
- import fr.crafttim.chat.client.network.ClientSide;
- import fr.crafttim.chat.client.ui.ChatWindow;
- import fr.crafttim.chat.client.ui.ConnectWindow;
- public class ChatClient {
- private ClientSide clientSide;
- private ConnectWindow connectUI;
- private ChatWindow ui;
- public ChatClient(){
- clientSide = new ClientSide(this);
- showConnectUI();
- }
- private void showConnectUI() {
- connectUI = new ConnectWindow(this);
- connectUI.setLocationRelativeTo(null);
- connectUI.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- connectUI.setVisible(true);
- }
- public void onConnected(){
- clientSide.start();
- setupGUI();
- }
- private void setupGUI() {
- connectUI.setVisible(false);
- connectUI.dispose();
- ui = new ChatWindow(this);
- ui.setTitle("D-Net Chat");
- ui.setPreferredSize(new Dimension(640, 480));
- ui.validate();
- ui.pack();
- ui.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- ui.setLocationRelativeTo(null);
- ui.setVisible(true);
- }
- public ChatWindow getWindow(){
- return this.ui;
- }
- public ClientSide getClientSide(){
- return this.clientSide;
- }
- public static void main(String[] args){
- try {
- UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
- new ChatClient();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement