title: How to update values of a JFrame main after using a JDialog of Java Swing?
body: <p>I have a main window called MainFrame which is a jForm to which I update the data depending on a timer, but the problem is that I cannot update the data in the same MainFrame after using the jdialog, since I end up creating another duplicate window, but with the data changed, one with the original timer and the other with the new timer, I know that I can close the first window with dispose() and then keep the second, but I would like to avoid changing windows so much</p>
  <p>the code with which I create another window when pressing the jDialog button is the following</p>
  <pre><code>private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
          // TODO add your handling code here:
  
          String textoFieldTimer = jTextField1.getText();
  
          int timeUserConfig = Integer.parseInt(textoFieldTimer);
          
          Timer timeDefault = new Timer(timeUserConfig, null);
          
          TokenAccess token = new TokenAccess();
          token.access_code = code;
  
          MainFrame mainFrame = new MainFrame(token);
          mainFrame.setVisible(true);
  
          mainFrame.timeDefault.stop();
          mainFrame.timeDefault = timeDefault;
          
          mainFrame.setUpdateTime(timeUserConfig);
          this.dispose();
  
      }//GEN-LAST:event_jButton1ActionPerformed
  </code></pre>
  <p>Is there any alternative to update the window? something like <code>mainFrame.update();</code> or maybe send the value of the jTextField from the jDialog to mainFrame? since the previous code creates another MainFrame for me.</p>
  <p>Method main setLabel and Timer.start/stop</p>
  <pre><code>public void setUpdateTime(int timeUserConfig) {
          this.timeUserConfig = timeUserConfig;
          if (timeUserConfig == 0) {
              timeDefault.start();
              timeDefault.addActionListener(new java.awt.event.ActionListener() {
                  @Override
                  public void actionPerformed(java.awt.event.ActionEvent evt) {
                      setLabelText();
                      String timeUserConfigStr = Integer.toString(timeDefaultInt);
                      tiempoActualizado.setText(&quot;Tiempo de Actualizado: &quot; + timeUserConfigStr+&quot;ms&quot;);
                  }
              });
          } else {          
              timeDefault.stop();
              timeDefault = new Timer(timeUserConfig, null);
              timeDefault.start();
              timeDefault.addActionListener(new java.awt.event.ActionListener() {
                  @Override
                  public void actionPerformed(java.awt.event.ActionEvent evt) {
                      setLabelText();
                      String timeUserConfigStr = Integer.toString(timeUserConfig);
                      tiempoActualizado.setText(&quot;Tiempo de Actualizado: &quot; + timeUserConfigStr+&quot;ms&quot;);
                  }
              });
          }
      }
  </code></pre>
  <p>setLabelText is a method set of label</p>
  <pre><code>public void setLabelText() {
  
          String humedadStr = String.valueOf(humedad);
          String temperaturaStr = String.valueOf(temperatura);
          String presionStr = String.valueOf(co2);
  
          temporalHum.setText(humedadStr);
          temporalTemperatura.setText(temperaturaStr);
          temporalPresion.setText(presionStr);
      }
  </code></pre>
  <p>Any help would be appreciated.</p>