Browse Source

DnD: Ensure #createDragImage returns a BufferedImage, as this is what the DnD API expects.

pull/245/head
weisj 3 years ago
parent
commit
464ba398c7
No known key found for this signature in database
GPG Key ID: 31124CB75461DA2A
  1. 17
      core/src/main/java/com/github/weisj/darklaf/util/DnDUtil.java

17
core/src/main/java/com/github/weisj/darklaf/util/DnDUtil.java

@ -22,25 +22,28 @@
package com.github.weisj.darklaf.util;
import java.awt.*;
import java.awt.image.BufferedImage;
import com.github.weisj.darklaf.graphics.PaintUtil;
import com.github.weisj.darklaf.util.graphics.ScaledImage;
public final class DnDUtil {
public static Image createDragImage(final Component c, final int lw, final Color borderColor) {
public static BufferedImage createDragImage(final Component c, final int lw, final Color borderColor) {
return createDragImage(c, new Rectangle(0, 0, c.getWidth(), c.getHeight()), lw, borderColor);
}
public static Image createDragImage(final Component c, final Rectangle bounds, final int lw,
public static BufferedImage createDragImage(final Component c, final Rectangle bounds, final int lw,
final Color borderColor) {
Image tabImage = ImageUtil.scaledImageFromComponent(c, bounds);
int w = tabImage.getWidth(null);
int h = tabImage.getHeight(null);
Graphics g = tabImage.getGraphics();
ScaledImage tabImage = ImageUtil.scaledImageFromComponent(c, bounds);
int w = tabImage.getWidth(c);
int h = tabImage.getHeight(c);
Graphics g = tabImage.getGraphics();
g.setColor(borderColor);
PaintUtil.drawRect(g, 0, 0, w, h, lw);
g.dispose();
return tabImage;
// The DnD api expects a BufferedImage. So we need to unwrap the delegate.
return tabImage.getDelegate();
}
}

Loading…
Cancel
Save