1

Is there an easy way to change JToolbars floating image like the drag image in transferhandlers without having to code an own transferhandler?

Corn
  • 47
  • 7

1 Answers1

0

Apparently paintDragWindow in the ToolbarUI does the thing.

I used this code which create an image of my toolbar as floating img.

@Override
protected void paintDragWindow(Graphics g) {
    BufferedImage img = getScreenShot(this.toolBar);
    g.drawImage(img, 0, 0, null);
    g.setColor(dragWindow.getBorderColor());

    g.drawRect(0, 0, toolBar.getWidth() - 1, toolBar.getHeight() - 1);
    System.out.println("paint drag window");
}

public static BufferedImage getScreenShot(Component component) {

    BufferedImage image = new BufferedImage(component.getWidth(),
            component.getHeight(), BufferedImage.TYPE_INT_RGB);
    // call the Component's paint method, using
    // the Graphics object of the image.
    component.paint(image.getGraphics()); // alternately use .printAll(..)
    return image;
}
Corn
  • 47
  • 7