title: Opening new JPane on JButton click & call logic not working as expected
body: <p>I'm trying to have a new JPane on JButton click &amp; after that call another method. But the method logic is implemented first &amp; the new JPane is displayed.</p>
  <pre><code>public void actionPerformed(ActionEvent e) {
      if(e.getSource() == NextButton) {
          String text = userText.getText(); 
          panelContainer.removeAll();
          panelContainer.setSize(0,0);
          panelContainer.setSize(secondPanel.getSize());
          panelContainer.add(secondPanel);
          panelContainer.revalidate();        
          logic();
      }
  </code></pre>
  <p>}</p>
  <p>SecondPanel is displayed after completion of logic(), but I want the other way.</p>
  <p>Please suggest.</p>