private void createMenu() {
        JMenuBar menuBar = new JMenuBar();
        JMenu fileMenu = new JMenu("File");
        menuBar.add(fileMenu);


        JMenuItem menuItem = new JMenuItem("New connection");
        fileMenu.add(menuItem);

        menuItem.addActionListener(new AbstractAction() {
            @Override
            public void actionPerformed(ActionEvent e) {
                NewConnectionDialog connectionDialog = new NewConnectionDialog(MainFrame.this);
                connectionDialog.setVisible(true);
                String server = connectionDialog.getServerAddress();
                int serverPort = connectionDialog.getServerPort();
                try {
                    serverManager.connect(server, serverPort);
                    boolean acceptedUserCredentials = false;
                    while (!acceptedUserCredentials) {
                        UserNameDialog userNameDialog = new UserNameDialog(MainFrame.this);
                        userNameDialog.setVisible(true);
                        String userName = userNameDialog.getUserName();
                        EnterResult enterResult = serverManager.tryEnter(userName);
                        if (enterResult.isSucceed()) {
                            acceptedUserCredentials = true;
                            setTitle(getTitle() + " - " + userName);
                        } else {
                            JOptionPane.showMessageDialog(MainFrame.this,
                                    "Cant enter",
                                    "Inane error",
                                    JOptionPane.ERROR_MESSAGE);
                        }

                    }


                        serverManager.getResponseReceiver().addErrorHandler(errorHandler);

                        serverManager.requestUserList();
                        UserListAnswer userListAnswer = (UserListAnswer) serverManager.getReadedAnswer();
                        List<UserInfo> userList = userListAnswer.getUsers();
                        userListPanel.setUsers(userList);
                        enabledSendControls(true);

                } catch (IOException e1) {
                    JOptionPane.showMessageDialog(MainFrame.this,
                            "Error connect to server",
                            "Inane error",
                            JOptionPane.ERROR_MESSAGE);
                    try {
                        serverManager.close();
                    } catch (IOException e2) {

                    }
                }
            }
        });

        JMenuItem exitItem = new JMenuItem("Exit");
        fileMenu.add(exitItem);
        exitItem.addActionListener(new AbstractAction() {
            @Override
            public void actionPerformed(ActionEvent e) {
                try {
                    serverManager.getResponseReceiver().removeHandler(errorHandler);
                    serverManager.logout();
                } catch (IOException e1) {

                } finally {
                    System.exit(0);
                }
            }
        });

        addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
                try {
                    serverManager.getResponseReceiver().removeHandler(errorHandler);
                    serverManager.logout();
                } catch (IOException e1) {
                    e1.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
                }  finally {
                    System.exit(0);
                }
            }
        });

        this.setJMenuBar(menuBar);


    }