title: Java: How to reset a JFrame?
body: <p>setVisible currently use to restart the methods, but the transition does a flashing, is there any instruction other than setVisible? leave it in its initial state. reset button on the last Frame_1 only to return to the initial state.</p>
  
  <pre><code>   public class frame_1 extends javax.swing.JFrame {
  
     private void btnfinishActionPerformed(java.awt.event.ActionEvent evt) {                                         
          Period total = new Period(0, totalDuration, PeriodType.yearMonthDay());
          txta.append("________________________________________________" + "\n");
          txta.append("Duracion total: " + total.getYears() + " years " + total.getMonths() + " Months " + total.getDays() + " Days " + "\n");
          txtini.setText(null);
          txtfin.setText(null);
  }                                        
  
  private void btnaddActionPerformed(java.awt.event.ActionEvent evt) {                                        
          period();
          txtini.setText(null);
          String fu = principio.txtingresa.getText();
          txtfin.setText(fu);
  }                                       
  
  public void period(){
          SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
  
          String startDate = txtini.getText();
          String endDate = txtfin.getText();
  
          Date start = null;
          Date end = null;
      try {
          start = sdf.parse(startDate);
          end = sdf.parse(endDate);
      } catch (ParseException ex) {
          Logger.getLogger(fecha_1.class.getName()).log(Level.SEVERE, null, ex);
      }
  
          if(end.getTime() &lt; start.getTime()){
              JOptionPane.showMessageDialog(null, "the date finish y higher.!");
              txtini.setText(null);
              txtfin.setText(null);
          }else{
          long duration = end.getTime() - start.getTime();
          Period period = new Period(0, duration, PeriodType.yearMonthDay());
  
          txta.append(startDate + " - "+ endDate + "     =     " + period.getYears()+ "  years  " + period.getMonths() + "  Months  " + period.getDays() + "  Days  " + "\n");
          totalDuration += duration;
          }
          txtini.requestFocusInWindow();
  }
  
     private void btnrestartActionPerformed(java.awt.event.ActionEvent evt) {                                        
          frame_1 obj1 = new frame_1();
          obj1.setVisible(false);
          obj1.setVisible(true);
          }
  
       }
  </code></pre>