Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: OutOfMemoryException During Drag and Drop From a Tree



on 27/11/02 11:28 PM, Shankman, Gordon L. at email@hidden
wrote:

> I am running into a problem when trying to do drag and drop from a
> large JTree (about 3000 leaves). The default behavior under Mac OS X
> 10.2 seems to be to create a translucent image of the entire tree
> during the drag operation and display that image during the drag. I
> have the JTree displayed in a JScrollPane but the created image is the
> entire tree, not just the visible portion. The creation of this image
> causes an OutOfMemoryException that prevents the drag operation from
> beginning. Is there a non-Mac specific way to stop this image from
> being created or to force it to only display the visible portion of the
> tree? I have to be able to compile and run the code on other systems
> as well (Linux and Windows) so I can't do anything specific to OS X.
>
> Thanks to anyone who can help,
> Gordon Shankman
>snip<

I've had this problem. I think I previously did something like the following
in my dragGestureRecognized method.

Rectangle bounds =getPathBounds(path);
Component renderer = getCellRenderer().getTreeCellRendererComponent(
this,item,true,false,item.isLeaf(),
this.getRowForPath(path),true);
renderer.setSize(bounds.width,bounds.height);
Image image = createImage(bounds.width,bounds.height);
Graphics g = image.getGraphics();
renderer.paint(g);
g.dispose();

int act = dge.getDragAction();
switch(act){
case DnDConstants.ACTION_COPY:
dge.startDrag(DragSource.DefaultCopyNoDrop,image,...


Hope it helps.

cheers

Brooklyn Waters
============================================================
Senior Manager R&D
Dugite Pty Ltd ,-_|\
Nedlands, W.A. 6907 / \
AUSTRALIA --> *_,-._/
e-mail : email@hidden v
phone : +618 9386 7433
facsimile : +618 9386 7411
http://www.dugite.net.au/
============================================================
This communication is intended the addressee only, you may
not forward or deliver this communication to anyone else. We
will not be liable for any unauthorised use of the contents
of this communication.

If you are not the intended recipient of this communication
please notify Brooklyn Waters (email@hidden).
_______________________________________________
java-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/java-dev
Be sure to read the FAQ http://developer.apple.com/java/faq/ before posting
Do not post admin requests to the list. They will be ignored.

References: 
 >OutOfMemoryException During Drag and Drop From a Tree (From: "Shankman, Gordon L." <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.