JLabel lbl2 = new JLabel(mDragNode);
lbl2.setForeground(Color.white);
lbl2.setVisible(true);
lbl2.setFont(this.getFont());
Point ptDragOrigin = e.getDragOrigin();
Point ptOffset = new Point();
TreePath path = getPathForLocation(ptDragOrigin.x, ptDragOrigin.y);
Point raPath = getPathBounds(path).getLocation();
ptOffset.setLocation(ptDragOrigin.x - raPath.x, ptDragOrigin.y
- raPath.y);
mGhostRect.setRect(ptOffset.x, ptOffset.y,
lbl2.getPreferredSize().width, lbl2.getPreferredSize().height);
lbl2.setSize(lbl2.getPreferredSize());
mGhostImage = new BufferedImage(lbl2.getWidth(), lbl2
.getHeight(), BufferedImage.TYPE_INT_ARGB_PRE);
mTreeImage = new BufferedImage(this.getWidth(), this.getHeight(),
BufferedImage.TYPE_INT_ARGB_PRE);
Graphics2D g2t = mTreeImage.createGraphics();
this.paint(g2t);
g2t.dispose();
// Get a graphics context for this image
Graphics2D g2 = mGhostImage.createGraphics();
// Ask the cell renderer to paint itself into the BufferedImage
lbl2.paint(g2);
// Use DST_OVER to cause under-painting to occur
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.DST_OVER,
0.5f));
Color c1 = new Color(UIManager.getDefaults().getColor(
"Tree.selectionBackground").getRGB());
c1 = c1.darker();
g2.setPaint(new GradientPaint(0, 0, c1, getWidth(), 0, new Color(255,
255, 255, 0)));
// Paint under the JLabel's text
g2.fillRect(0, 0, getWidth(), mGhostImage.getHeight());
// Finished with the graphics context now
g2.dispose();
mCurrentPoint = e.getDragOrigin();
e.startDrag(null, mGhostImage, new Point(15, 5),
new TransferNode(), this);
}
} catch (Exception ee) {
((PluginTreeModel) this.getModel()).setDisableUpdate(false);