title: Swing remove component from container and repaint
body: <p>I have implemented a Navigation tree extending JTree. For every click on a node, a form providedby the node will be displayed after the previous form has been removed.</p>
  
  <p>If no form is provided by the node, the old form is simply rmoved.</p>
  
  <p>My problem is that the part of displaying the first form works, but when I click on a node without a form (null), the old form is still being displayed until I e.g. resize the window.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>public class NavigationTree extends EncoTree {
  
  private Container target = null;
  
  public NavigationTree(Color from, Color to, Container trg) {
      super(from, to);
      this.target = trg;
  
      this.addMouseListener(new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent me){
              TreePath tps = getSelectionPath();
              if(tps != null){
                  cstmMutableTreeNode node = (cstmMutableTreeNode) getLastSelectedPathComponent();
                  target.removeAll();     
                  if(node.form != null){
                      node.form.construct();
                      node.form.setPreferredSize(new Dimension(200, target.getSize().height));
  
                      target.add(node.form, BorderLayout.PAGE_START);
  
                  }
                  target.validate();
              }
          }
      });
  }
  </code></pre>
  
  <p>}</p>
  
  <p>As far as I understand it a <code>repaint()</code> request should be enqueued in the EDT as soon as I revalidate the container.</p>
  
  <p>So, why does displaying a the first form work without having to resize the window, but simply removing components does not?</p>