title: Listen to JFrame resize events as the user drags their mouse?
body: <p>When a user clicks on the corner of a JFrame to resize and drags the mouse around, the JFrame redraws based on the current position of the mouse as the user drags. How can you listen to these events?</p>
  
  <p>Below is the what I have currently tried:</p>
  
  <pre><code>public final class TestFrame extends JFrame {
      public TestFrame() {
          this.addComponentListener(new ComponentAdapter() {
              public void componentResized(ComponentEvent e) {
                  // This is only called when the user releases the mouse button.
                  System.out.println("componentResized");
              }
          });
      }
  
      // These methods do not appear to be called at all when a JFrame
      // is being resized.
      @Override
      public void setSize(int width, int height) {
          System.out.println("setSize");
      }
  
      @Override
      public void setBounds(Rectangle r) {
          System.out.println("setBounds A");
      }
  
      @Override
      public void setBounds(int x, int y, int width, int height) {
          System.out.println("setBounds B");
      }
  }
  </code></pre>
  
  <p>How can I determine and constrain how the user resizes a window (based on the current aspect ratio of the window) as they are dragging around the mouse around?</p>