title: How to clear a JFrame?
body: <p>I'm still a noob to Swing classes and I wanted to clear the screen after the user activates a button.</p>
  <pre><code>    JButton tes=new JButton(&quot;TEST&quot;);
      tes.setBounds(550, 375, 200, 75);
      tes.setFocusable(false);
      tes.setFont(new Font(&quot;comic sans&quot;,Font.PLAIN,20));
      tes.setBackground(Color.white);
      tes.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2, true));
      tes.addActionListener(new ActionListener(){
          @Override
          public void actionPerformed(ActionEvent e) {
              try {
                  test('T');
              }
              catch(IOException e1) {
                  throw new UncheckedIOException(e1);
              }
          }
      });
  
      f.add(tit);f.add(sub);
      f.add(pr);f.add(tes);
      f.setVisible(true);
  }
  
  </code></pre>
  <p>I have used the following and it didn't really do anything.</p>
  <pre><code>removeAll()
  revalidate();
  repaint(); 
  </code></pre>