IDEA-127438 Tool windows drag&drop failure under Java 7
authorVassiliy <vassiliy.kudryashov@jetbrains.com>
Thu, 17 Jul 2014 14:42:32 +0000 (18:42 +0400)
committerVassiliy <vassiliy.kudryashov@jetbrains.com>
Thu, 17 Jul 2014 14:43:17 +0000 (18:43 +0400)
platform/platform-impl/src/com/intellij/openapi/wm/impl/StripeButton.java

index 7d534d5be545548200d1b9a75be79cfdfaa0ae1e..f62ff2c1819a87050740e22ff99ecb431c4e6e67 100644 (file)
@@ -30,6 +30,7 @@ import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.openapi.wm.ToolWindowAnchor;
 import com.intellij.ui.MouseDragHelper;
 import com.intellij.ui.PopupHandler;
+import com.intellij.util.ui.JBImageIcon;
 import com.intellij.util.ui.UIUtil;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
@@ -183,12 +184,22 @@ public final class StripeButton extends AnchoredButton implements ActionListener
       if (myDragPane == null) return;
       final BufferedImage image = UIUtil.createImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_ARGB);
       paint(image.getGraphics());
-      myDragButtonImage = new JLabel(new ImageIcon(image)) {
+      myDragButtonImage = new JLabel(new JBImageIcon(image)) {
 
         public String toString() {
           return "Image for: " + StripeButton.this.toString();
         }
       };
+
+      myDragButtonImage.addMouseListener(new MouseAdapter() {
+        @Override
+        public void mouseReleased(MouseEvent e) {
+          finishDragging();
+          myPressedPoint = null;
+          myDragButtonImage = null;
+          super.mouseReleased(e);
+        }
+      });
       myDragPane.add(myDragButtonImage, JLayeredPane.POPUP_LAYER);
       myDragButtonImage.setSize(myDragButtonImage.getPreferredSize());
       setVisible(false);