0

my question relates to java gui with netBeans i'm trying to call a function from a TextField "Block" but some how my gui freezing's when I do the following: by the way if it's matters the other function called "startconnection();" are private to... (p.s->Forgive me for my english...)

 private void userTextActionPerformed(java.awt.event.ActionEvent evt) {                                         
        String str = evt.getActionCommand();
        if(connected)
        sendMessage(str);
        else{
                 if((str.length() > 10) && 
                       (str.subSequence(0, 9).equals("<connect>")) && 
                       (str.charAt(9)== '<' )&&
                       (str.charAt(str.length()-1) == '>')&&
                       (!connected))
                {
                    clientName = str.substring(10, str.length()-1);
                    userText.setText("");
                    startConnection();//sweet spot!! this is where i'm stack...
                }else{
                    chatArea.append("Invalid input if you want to connect\nplease type '<connect><Your Name>'\n");
                }

        }      
    }    
Ian Kenney
  • 6,376
  • 1
  • 25
  • 44
  • 1
    Probably need to run startConnection() inside a SwingWorker, which puts it inside a thread that is not servicing GUI events. – Lee Meador Apr 30 '13 at 22:00
  • Is your GUI freezing for few moments? Or It hangs up and you have to terminate the program forcefully? – Vishal K Apr 30 '13 at 22:04
  • startConnection() is probably blocking until a connection is started. Follow @LeeMeador 's advice. – Sinkingpoint May 01 '13 at 00:02

0 Answers0