title: The contents of my JComponent only refresh after a manual resize
body: <p>I am trying to figure out why my JComponent refreshes when I manually drag my window, but it doesn't refresh when I call repaint or revalidate. The data is ready to be displayed, but it just won't show until I manually resize. Can anybody give some suggestions about what I can do or does this sound like it isn't a Swing problem since I tried repaint and revalidate?</p>
  
  <p>One weird things I've noticed is that if I have this code:</p>
  
  <pre><code>sp.setSize(sp.getSize().width, sp.getSize().height+1);
  sp.setSize(sp.getSize().width, sp.getSize().height-1);
  </code></pre>
  
  <p>If the first line is used, then the JComponent will refresh itself. If I use none or both of these lines it will not, which seems bizarre to me.</p>
  
  <p>I am basically just putting a JPanel in a JInternalFrame in a JDesktopPane. There are two main functions for what I am trying to do. One adds the new JPanel and the other tries to refresh it so the new data will show:</p>
  
  <pre><code>public void addNewSP()
   {
  sp = new JInternalFrame("SP");
    sp.setClosable(true);
    sp.setLocation(700, 400); //this should be changed to something based on screen size
    sp.setResizable(true);
    sp.add(popUp);
    this.parentContainer.add(sp, JLayeredPane.DRAG_LAYER);
    sp.pack();
    sp.show();
    sp.setSize(500, 500);
    sp.setPreferredSize(new Dimension(500, 500));
  }
  
  public void refreshSP()
   {
  
    sp.repaint();
    sp.validate();
    sp.repaint();
  
    sp.validate();
    parentContainer.validate();
    parentContainer.repaint();
  
    sp.setSize(sp.getSize().width, sp.getSize().height+1);
    sp.setSize(sp.getSize().width, sp.getSize().height-1);
    }
   }
  </code></pre>
  
  <p>BTW parentContainer is the JDesktopPane</p>