The elements change only after another action



  • tf.username.setEnabled(false);
    tf.password.setEnabled(false);
    tf.cb.setEnabled(false);
    tf.button.setEnabled(false);
    tf.imageLabel.setVisible(true);
    
    Parser pars=new Parser(user, password);
    String[] answer=pars.getData();
    

    tf - That's it. JPanel♪ ♪ Parser departures GET and POST by request Apache HtpClient and then work. ExcelApache Poi

    The problem is that the change on board occurs only after the end of the method getData()



  • Problem is, you've got performance. getData() It's in the same flow as the GUI's. Put it in a separate flow and it's gonna be okay, read the offs for a more detailed understanding. https://docs.oracle.com/javase/tutorial/uiswing/concurrency/ and special attention https://docs.oracle.com/javase/tutorial/uiswing/concurrency/dispatch.html

    I mean, in your case there must be something like that:

    tf.username.setEnabled(false);
    tf.password.setEnabled(false);
    tf.cb.setEnabled(false);
    tf.button.setEnabled(false);
    tf.imageLabel.setVisible(true);
    

    new Thread(new Runnable() {
    @Override
    public void run() {
    Parser pars=new Parser(user, password);
    String[] answer=pars.getData();
    // Все остальные действия с результатом
    }
    }).start();




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2