title: Java How to thread a GUI
body: <p>So I have a button that opens a while loop, then my whole GUI freezes until the while loop is over, with that being said how would I thread my GUI to update every second or so?</p>
  
  <pre><code>JButton Test= new JButton();
  Test.setText("Test");
  Test.setSize(230, 40);
  Test.setVisible(true);
  Test.setLocation(15, 290);
  
  Test.addActionListener(new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent e){
  int x = 0;
  while(x&lt;500){
      x++
  });
  </code></pre>