@Override
                public void actionPerformed(ActionEvent e) {
                    String networkName = networkNameField.getText().trim();
                    String server = serverField.getText().trim();
                    String port = portField.getText().trim();
                    String nick = nickField.getText().trim();
                    String pass = passField.getText().trim();

                    if (networkName.isEmpty() || server.isEmpty() || port.isEmpty() || nick.isEmpty()) {
                        JOptionPane.showMessageDialog(dialog, "Network name, server, port and nick are required");
                    } else {
                        dialog.dispose();
                        Connection.nicks[0] = nick;

                        for (int i = 0; i < tabbedPane.getTabCount(); i++) {
                            ChannelPanel channel = (ChannelPanel) tabbedPane.getComponentAt(i);
                            if (networkName.equals(channel.title)) {
                                tabbedPane.setSelectedComponent(channel);
                                String[] msg = {null, "You are already connected to " + networkName + "."};
                                try {
                                    channel.insertString(msg, errorStyle, false);
                                } catch (BadLocationException | IOException ex) {
                                    Logger.getLogger(GUI.class.getName()).log(Level.SEVERE, null, ex);
                                }
                                return;
                            }
                        }

                        Connection c = new Connection(networkName, server, Integer.valueOf(port), false);
                        if (!pass.isEmpty()) c.password = pass;
                    }
                }