title: Trying to popup a panel in Java
body: <p>Okay, i don't want to use other 3rd party libraries right now. Trying to make own stuff.</p>
  
  <p>You guys know how the date control in Windows is/was? Looked like a plain textbox with a button next to it and on clicking a button, a new smaller window/calendar opened to select dates. This window does not shove off the other controls...it is like on top of all of them.</p>
  
  <p>I am trying to do the same in Java. I could only get so far....</p>
  
  <pre><code>import java.awt.*;
  import java.awt.event.*;
  import javax.swing.*;
  
  class PopupPanelDemo{
  public static void main(String ags[]){
      JFrame f = new JFrame();
      JLabel l = new JLabel("Date");
      JTextField t = new JTextField(10);
      JPanel p = new JPanel();
      JButton b =  new JButton("Show");
  
      p.setBorder(BorderFactory.createLineBorder(Color.black,1));
      p.setBackground(Color.red);
      p.setVisible(false);
  
      f.setLayout(new FlowLayout());
      f.add(l);
      f.add(t);
      f.add(b);
      f.add(p);
  
      f.setSize(400,400);
      f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      f.setLocationRelativeTo(null);
      f.setVisible(true);
  
      b.addActionListener(new ActionListener(){
          public void actionPerformed(ActionEvent e){
              p.setSize(t.getWidth(), t.getHeight());
              p.setLocation(t.getLocation().x, t.getLocation().y + t.getHeight());
              p.setVisible(true);
          }
      });
  }
  }
  </code></pre>
  
  <p>I have not got it to work properly. The JPanel displays correctly, as intended in the code only when i click the button twice.</p>
  
  <p>Is there a HTML like zindex stuff in java?</p>
  
  <p>Is this the right route or is there some other control that i should check? </p>
  
  <p>PS. The JPanel will be substituted by my calendar panel. I just included the necessary stuff here.</p>
  
  <p>I am using Window 8.1 and Java 1.8.0_45.</p>