title: Java Open a JFrame relative to the position of a button (menu like behaviour)
body: <p>I am trying to implement expand functionality like in below example, however instead of a menu I am using a JFrame which contains more sophisticated GUI elements. 
  <img src="https://i.stack.imgur.com/cmhpk.jpg" alt="enter image description here">
  The problem I run into is that if I move the parent window which contains the button below which the frame should appear, I can not adjust my custom JFrame to open each time relative to the position of that button</p>
  
  <p>initially I simply used</p>
  
  <pre><code>myCustomFrame.setLocation(myButton.getX(), (myButton.getY() + 73));
  </code></pre>
  
  <p>but this obviously doesn't work if I change move the parent window</p>
  
  <p>After that I tried</p>
  
  <pre><code>myCustomFrame.setLocationRelativeTo(myButton);
  </code></pre>
  
  <p>but in this case it appears at the top of the button... I adjust the position for a particular case, but this is not a solution.</p>
  
  <p>So I am trying to get the same behavior as menus have, such  that the position of the JFrame is automatically adjusted.</p>
  
  <p>Does anyone have any suggestions?</p>