private void jButton30MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton30MouseClicked
            
           String add = jTextField41.getText();
           String port = jTextField42.getText();
           
           if(!add.equals("") && !add.contains("x")) {          // check if ip is set
               
               if(!port.equals("")) {                           // check if the port is set
         
                   int i = Client.Utils.setSettings(add, port);

                   if(i == 0) {             // settings have been successfully stored     

                       try {
                       
                           Client.ServerInfo settings = Utils.getSettings();

                           Socket s = Client.Utils.open(settings.getAddress(), settings.getPort());     // try to open the connection

                           if(s != null) {          // socket successfully created
                               
                               try {
                                   JOptionPane.showMessageDialog(this, "Connessione col server ok.", "Connessione", JOptionPane.INFORMATION_MESSAGE);
                                   s.close();
                                    closeSettingBox();      // close if it's all ok
                               } catch (IOException ex) {
                                   JOptionPane.showMessageDialog(this, "Errore in connessione. Riavviare l'applicazione.", "Error", JOptionPane.ERROR_MESSAGE);
                               }
                               
                            } else {                // socket has not been created, so there's something wrong
                               JOptionPane.showMessageDialog(this, "Connessione col server non riuscita.", "Error", JOptionPane.ERROR_MESSAGE);
                            }
                       
                       } catch (FileNotFoundException e) {
                           // the file is just have been created
                       } catch (UnknownHostException e) {       // unknown host
                           JOptionPane.showMessageDialog(this, "Host sconosciuto: controllare l'indirizzo del server.", "Error", JOptionPane.ERROR_MESSAGE);
                       } catch (IOException e) {                // IOException
                           JOptionPane.showMessageDialog(this, "Errore " + e.getLocalizedMessage(), "Error", JOptionPane.ERROR_MESSAGE);
                       }
                       
                   } else
                       JOptionPane.showMessageDialog(this, "Errore durante la creazione del file di impostazioni. Riprovare.", "Error", JOptionPane.ERROR_MESSAGE);
                  
                   
                } else      // port has not been inserted
                   JOptionPane.showMessageDialog(this, "Inserire il numero della porta del server.", "Error", JOptionPane.ERROR_MESSAGE);
               
           } else       // address has not been inserted
               JOptionPane.showMessageDialog(this, "Inserire l'indirizzo del server.", "Error", JOptionPane.ERROR_MESSAGE);        
           
        // TODO add your handling code here:}//GEN-LAST:event_jButton30MouseClicked

        }