有没有一种简单的方法来更改 JToolbars 浮动图像,例如传输处理程序中的拖动图像,而无需编写自己的传输处理程序?
问问题
33 次
1 回答
0
显然 ToolbarUI 中的paintDragWindow 可以做到这一点。
我使用此代码将我的工具栏图像创建为浮动 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;
}
于 2014-09-12T10:02:10.883 回答