public JavaClient() {
    	// XXX Later for chess
        //ResModel.init(this.getClass());
        this.view = new ClientViewPanel();
        
        // Add listeners
        view.getFrame().addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent winEvt) {
                if(thread != null)
                    thread.running = false;
                if(isConnected())
                    sendMessage("DCON;Window Closed");

                System.exit(0);
            }
        });
        
        SendListener listener = new SendListener();
        view.getSouthPanel().getInputBox().addActionListener(listener);
        view.getSouthPanel().getSendButton().addActionListener(listener);
        
        MouseListener mouseListener = new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
                if (e.getClickCount() == 2) {
                    int index = view.getUserList().locationToIndex(e.getPoint());
                    //follow player into game
                    UsernameModel user = (UsernameModel)(view.getListModel().getElementAt(index));
                    if(user != null)
                        sendMessage("MSG;/follow "+user.getName());
                }
            }
        };
        view.getUserList().addMouseListener(mouseListener);
        
        // Allow users to follow friends into game
        ActionListener followActionListener = new ActionListener() {
            public void actionPerformed(ActionEvent actionEvent) {                  
            	UsernameModel user = (UsernameModel)view.getUserList().getSelectedValue();
                if (user != null)
                   sendMessage("MSG;/follow "+user.getName());
            }
    	};                
    	view.getFollowButton().addActionListener(followActionListener);
    	
    	// Fills the input box with a command to send user a message
        ActionListener messageActionListener = new ActionListener() {
            public void actionPerformed(ActionEvent actionEvent) {                  
            	UsernameModel user = (UsernameModel)view.getUserList().getSelectedValue();
                if(user == null)
                    return;

                view.getSouthPanel().getInputBox().setText("/msg " + user.getName() + " ");
                view.getSouthPanel().getInputBox().requestFocus();
            }
    	};                
    	view.getMessageButton().addActionListener(messageActionListener);
    	
    	// Default offline mode
    	ActionListener connectActionListener = new ActionListener() {
            public void actionPerformed(ActionEvent actionEvent) {
            	OfflineViewPanel offlinePanel = (OfflineViewPanel) view.getCanvas();
            	connect(offlinePanel.getIp_box().getText(),Integer.parseInt(offlinePanel.getPort_box().getText()));
            }
    	};
    	OfflineViewPanel offlinePanel = (OfflineViewPanel) view.getCanvas();
    	offlinePanel.getConnectButton().addActionListener(connectActionListener);
    	
    	// Add cell renderer
    	JList userList = view.getUserList();
    	userList.setCellRenderer(new MyCellRenderer());
    	view.setUserList(userList);
    	
        //TODO: use the standardized list!!

        location = -1;
    }