/* LanguageTool, a natural language style checker 
 * Copyright (C) 2016 Daniel Naber (http://www.danielnaber.de)
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
 * USA
 */
package org.languagetool.gui;

import java.awt.Frame;
import java.awt.Rectangle;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import javax.swing.JFrame;

/**
 * A class that listens a window for resize events and saves its bounds.
 *
 * @author Panagiotis Minos
 * @since 3.4
 */
class ResizeComponentListener extends ComponentAdapter {

  private static final String BOUNDS_PROPERTY_NAME = "frame.bounds";

  static void attachToWindow(JFrame frame) {
    frame.addComponentListener(new ResizeComponentListener(frame));
  }

  static void setBoundsProperty(JFrame frame, Rectangle bounds) {
    frame.getRootPane().putClientProperty(BOUNDS_PROPERTY_NAME, bounds);
  }

  static Rectangle getBoundsProperty(JFrame frame) {
    return (Rectangle) frame.getRootPane().getClientProperty(BOUNDS_PROPERTY_NAME);
  }

  private final JFrame frame;

  private ResizeComponentListener(JFrame frame) {
    this.frame = frame;
  }

  @Override
  public void componentResized(ComponentEvent e) {
    if ((frame.getExtendedState() & Frame.MAXIMIZED_BOTH) == 0) {
      frame.getRootPane().putClientProperty(BOUNDS_PROPERTY_NAME,
              frame.getBounds());
    }
  }

}

@@ -1073,17 +1073,19 @@
 ens 
-a
+for
  window 
 for 
@@ -1084,18 +1084,19 @@
 dow 
-for 
 resize
+/move
  eve
@@ -1871,24 +1871,161 @@
 tEvent e) %7B%0A
+    saveBounds();%0A  %7D%0A%0A  @Override%0A  public void componentMoved(ComponentEvent e) %7B%0A    saveBounds();%0A  %7D%0A%0A  private void saveBounds() %7B%0A
     if ((fra
@@ -2074,24 +2074,68 @@
 TH) == 0) %7B%0A
+      Rectangle bounds = frame.getBounds();%0A
       frame.
@@ -2191,40 +2191,15 @@
 AME,
-%0A              frame.getB
+ b
 ounds
-()
 );%0A 

save bounds of GUI on window move events (#573)