title: Java sliding JPanels
body: <p>I have a menu that has a variety of buttons on display, I'm able to make the buttons call their respective JPanels when clicked. The thing is I would like to make the Jpanel slide in when its called instead of instantaneously popping in. I tried using tween engine and as Java beginner,  I find it really overwhelming, so I decided to use timed animation.  I was able to make the Jpanel on top to slide to one side but for some reason the next panel doesn't want to display,  im really tired, can someone help please!  There code is below:</p>
  
  <pre><code>public class Listener implements ActionListener {
      @Override
      public void actionPerformed(ActionEvent e) {
  
          new Timer(0, new ActionListener() {
             public void actionPerformed(ActionEvent e) {                
  
                mainpane.setLocation(mainpane.getX() - 10, 0);
                if (mainpane.getX() + mainpane.getWidth() == 0) 
                {
                   ((Timer) e.getSource()).stop();
                     System.out.println("Timer stopped");
                } 
             }
          }).start();   
     } 
  }
  </code></pre>