Saving Images after doing drag and drop

Hi Frenz,
I'm doing on a program on drag and drop. Bascically, I have done 2 windows, one is the main window where the drag picture will be drop on and another one is the window with picture for me to drag.I want to know am I able to save_ the main windows with the "drag & drop" picture on it?
Your help will be very importnat to us..Thanks
cy.

Re,
If you want to capture the whole content of the window you should
create a BufferedImage of the size of the window and the default color model.
Then create the Graphics-object and call the paint method from the
root pane of the window.
// Create a BufferedImage
BufferedImage buf = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
// fetch the JRootPane
JComponent rootPane = getRootPane();
// create the graphics object
Graphics2D g2d = buf.createGraphics();
// do the paint
rootPane.paint(g2d);
g2d.dispose;to save this buffered image use the methods from javax.imageio.ImageIO.
Olek

Similar Messages

  • Double click after a drag and drop

    After I drag and drop a label(or other UIComponent)  in a container, i want to double click the label to show me an alert.  well it doesn't work.
    i've tried in the dragCompleteHandler to put  event.dragIntiator.addEventListener or  event.currentTargetaddEventListner but it doesn't work. Also i enabled  the DoubleClickEnabler and still nothing.
    Any ideas because i tried to google it and nothing came out with this problem.
    thanks

    And it does nothing similar when you drop an item on a folder or anything else, only the trash... Geez, that is pretty darn strange. And if you slowly drag and drop it, it does the same? I wonder if resetting your PRAM might be worth a shot.
    If you delete or remove the plist from where it is now I would guess that a new one would be created automatically like most preferences. But maybe you should wait for Baltwo on that one. Does force quitting the finder do anything? You might also try starting up in Safe Mode to see if that has any effect. If it does, there's probably some software conflict going on. Good luck, if you get it fixed post back. I'd really like to know what was going on.
    Steve

  • Why does drag and drop not work?

    Why does drag and drop not work?

    Do you mean that when you move files on the Desktop, they don't stay where you put them ?.
    If so - use Finder - View menu - Show View options & choose 'Arrange by' : none
    If not - please describe exactly what the problem is.

  • How to add imge to another image box by drag and drop

    Hi all
       i am using flex 3.and my problem is to drag an image and drop to another box or image what ever.just need to display the copy of the source image in its drop target.is it possible drag an image?if it is then how?please help me.
    thanks and regards

    there are examples of image dragging and dropping here:
    http://www.adobe.com/devnet/flex/quickstart/adding_drag_and_drop/
    i imagine for your problem, you want the final example, and instead of passing across an integer value, you want to pass across the image source.

  • Long delay after a drag and drop to trash

    This seems like a new behavior and I haven't changed anything: when I drag something to the trash there seems to be a delay in it actually "Getting in there," however if I right click and then click "Move to Trash" its immediate. Is this the way it should be? I am not using secure delete.

    And it does nothing similar when you drop an item on a folder or anything else, only the trash... Geez, that is pretty darn strange. And if you slowly drag and drop it, it does the same? I wonder if resetting your PRAM might be worth a shot.
    If you delete or remove the plist from where it is now I would guess that a new one would be created automatically like most preferences. But maybe you should wait for Baltwo on that one. Does force quitting the finder do anything? You might also try starting up in Safe Mode to see if that has any effect. If it does, there's probably some software conflict going on. Good luck, if you get it fixed post back. I'd really like to know what was going on.
    Steve

  • Songs don't show up in Library after a drag and drop

    I want to put some music on my daughters networked imac.
    ( right now we have her music 'shared' across the network) I want her to have more control of her music so she can make playlists etc (she is getting a nano unbeknownst to her )
    When I drop mp3 files into her iTunes folder they don't show in her library.
    Am I going about this the wrong way??

    Now I see the problem. I did not read your first post thoroughly enough.
    You already wrote they show up in the iTunes folder.
    iTunes doesn't recognize songs that are added this way.
    The most convenient way would be to copy the files to a folder on the desktop and after you're done, to drop that folder on the Library icon or the Library in iTunes.
    If 'Copy files to iTunes Music folder when adding to library' in Preferences>Advanced>General is checked, iTunes will copy those files to the proper place.
    Afterwards you can trash the contents of the folder on the desktop.
    M
    17' iMac fp 800 MHz 768 MB RAM   Mac OS X (10.4.6)   Several ext. HD (backup and data)

  • Why does drag and drop between instances of Safari not always work?

    I can drag a link from one instance of Safari to another and then without reason, it just stops working. Yet, if drag the link in one window to the address bar of the second it works just fine.  If I start a new instance of Safari I can drag to it just fine. If I start a new tab, I can drag to it fine (until it fails too). Any idea as what may cause this?
    Windows 7

    Do you mean that when you move files on the Desktop, they don't stay where you put them ?.
    If so - use Finder - View menu - Show View options & choose 'Arrange by' : none
    If not - please describe exactly what the problem is.

  • Drag and Drop and Image Size

    I need to be able to drag and drop images but I need them to be a certain size when I drag them out of an Aperture project. For various reasons, I don't want to use the export function. Only drag and drop will be efficient for the workflow that I"m planning. Problem is, the pixel dimension is not wide enough when I test it by pulling an image on to the desktop.
    My ultimate goal is drag them, sized and ready to go, and drop them onto a web browser upload page. I don't want to fumble with the extra steps of exporting them to another folder on the desktop and then upload the images from that folder to the browser.
    So does anybody know how or if it's possible to control the drag and drop SIZE /DIMENSION of an image?

    The drag and drop size is determined by your preview settings. What actually gets "dragged & dropped" is the preview, not the master file. You can control the quality and size of the preview in the Aperture preferences.

  • Can't import photos via drag-and-drop (only small thumbnail will appear)

    After I drag and drop photos into iPhoto 7.1.3 (even a photo just exported from iPhoto), it shows the import process and creates an untitled event. Once complete, I see a dashed-line box instead of the images.
    http://idisk.mac.com/phildame/Public/Pictures/Skitch/iPhoto-20080308-111415.jpg
    Every time I re-open, it will try and re-import the failed photos, creating a new event each time. I have to tell it not to try recoving.
    Note that in the event view, it's a blank square. If a reduce the thumbnail slider enough the images appear in "Photos" view (as if only the small thumbnails were generated before it crapped out).
    Is anyone else seeing this? I'm not sure what to do.
    Phil

    Phil
    Two issues there:
    Every time I re-open, it will try and re-import the failed photos,...
    Go to your Pictures Folder and find the iPhoto Library there. Right (or Control-) Click on the icon and select 'Show Package Contents'. A finder window will open with the Library exposed.
    Look there for a Folder called 'Import' or 'Importing'.
    Drag it to the Desktop. *Make no other changes*.
    Start iPhoto. Does that help?
    2. As to the blank thumbnails:
    Back Up and try rebuild the library: hold down the apple and option (or alt) keys while launching iPhoto. Use the resulting dialogue to rebuild.
    Regards
    TD

  • Problem with drag and drop on Mac

    Hi, when I run my AIR application on Windows, I'm able to do
    the drag and drop.
    But when I run the application on Mac, it gave me an
    allocation error: unable to allocate region of size <random
    number> after I drag and drop thrice.
    Anybody knows what's the reason?

    Pages does not support the Apple font used for color emoji, so that behavior is normal.
    With what app are you reading the yahoo mail?  There is really no guarantee than any other email service will show the special Apple font involved.
    You should have no problem putting emoji directly into Mail or Text edit via drag drop from the Character Viewer as shown below.
    You should also be able to upload graphics here easily by clicking on the camera icon.  My email is tom at bluesky dot org.

  • Drag and drop just to extract file path

    I'm writing a Cocoa GUI app to facilitate working with a command-line program. The scenario is quite similar to what I see in the Apple FileMerge.app. I'd have a NSView (or a drop pocket of whichever class appropriate) into which I can drag the file icons just in order to retrieve file's path, one by one, no visualization, no checking for file types, just for assembling a list of files to eventually be passed to the data crunching program as command line arguments. I've come across CocoaDragAndDrop sample program, which does great work in displaying dragged picture tiff and pdf files. Probably 90% of the code there is beyond what I need, but the semantics are so unlike anything I've ever come across (I'm miles away from image processing). I can't even figure where to start since everything seems so interconnected. Is there a simplest case example of Drag and drop which only serves file path extraction? From the aforementioned sample code I'm struggling to figure out what is the part which is absolutely needed only to retrieve the path? Do I have to init a [NSImage canInitWIthPasteboard: ... ...] if a file is a plain text file, or a raw data file? The app doesn't need to know what the file is, since passing the absolute path as text argument cannot do any harm in this case - the number crunching command line program takes care of the content. Do I need coders? Do I need a sourceOperationMaskForDragingContext? Does Drag and Drop even cover such trivial demands?
    Thanks in advance!
    Regards, UU

    Thanks for your kind replay. Please let's stay on-topic: my question shouldn't have pointed at if "Apple works like this or like that".
    IMHO, it's quit opposite: many things are cut-and-paste compatible, yet I'm missing few basic explanations.
    The following code can be derived from the API reference:
    #import "DragTView.h"
    #import "AppDelegate.h"
    @implementation DragTView
    - (id)initWithFrame:(NSRect)frame{
        self = [super initWithFrame:frame];
        if (self) [self registerForDraggedTypes:[NSArray arrayWithObject:NSFilenamesPboardType]];
        return self;
    - (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender{
        highlight=YES;
        [self setNeedsDisplay: YES];
        return NSDragOperationGeneric;
    - (void)draggingExited:(id <NSDraggingInfo>)sender{
        highlight=NO;
        [self setNeedsDisplay: YES];
    - (void)drawRect:(NSRect)rect
        [super drawRect:rect];
        if ( highlight ) {
            [[NSColor grayColor] set];
            [NSBezierPath setDefaultLineWidth: 5];
            [NSBezierPath strokeRect: rect];
    - (BOOL)prepareForDragOperation:(id <NSDraggingInfo>)sender {
        highlight=NO;
        [self setNeedsDisplay: YES];
        return YES;
    - (BOOL)performDragOperation:(id < NSDraggingInfo >)sender {
        NSArray *draggedFilenames = [[sender draggingPasteboard] propertyListForType:NSFilenamesPboardType];
        NSURL* fileURL;
        NSTextField* pathField = [(AppDelegate*)[[NSApplication sharedApplication] delegate] pathField];
        if (([[[draggedFilenames objectAtIndex:0] pathExtension] isEqual:@"txt"]){
            fileURL=[NSURL URLFromPasteboard: [sender draggingPasteboard]];
            [pathField setStringValue:  [fileURL path] ];
            return YES;
        } else return NO;
    - (void)concludeDragOperation:(id <NSDraggingInfo>)sender{
    @end
    It reveals the file path, yet, it boils down to fifty meaningless lines of code, since the pathField object (of class NSTextField) would itself reveal a dropped file's path without a single extra line of drag-and-drop code. What I find confusing is the following:
    How should a drag operation be set up, so a text file can be dragged to the DragTView object (declared as @interface DragView: NSImageView <NSDraggingSource, NSDraggingDestination>), which would than show the image of file's icon (without dragged file itself being an image file)? This is rather unclear in the documentation, with all due respect to Apple.
    Thanks in advance.

  • Really simple drag and drop example?

    I have just began exploring Adobe AIR and have succesfully
    managed to load images into an image component, through drag and
    drop from the desktop.
    Now I am trying to understand how to do the reverse —
    how to drag from the image component to the desktop, but after
    spending several hours googling I still haven't found an example
    that show how to achieve this. Either the samples are outdated,
    from the beta period, or to complicated for me to understand.
    Could someone please help me by showing how it is done, in
    the simplest possible way?
    Thanks in advance.

    Hi,
    You could let Christophe's excellent components do the heavy
    lifting for you:
    http://coenraets.org/blog/2007/06/air-to-desktop-drag-and-drop-two-simple-utility-classes/
    Or here's a good simple app with code that shows you how it's
    done:
    http://www.wabysabi.com/blog/2008/03/18/air-example-native-drag-n-drop-and-clipboard-integ ration/

  • Drag and Drop Problem, Drag Enter not getting called - Need Help

    While doing drag and drop on the nodes of JTRee dragGestureRecognized method is getting called,
    but after that no method is getting called, not even dragEnter.
    I am using TreePath as the Transferrable Object.
    public void dragGestureRecognized(DragGestureEvent gestureEvent)
               Point point=gestureEvent.getDragOrigin();
              TreePath path=sourceTree.getPathForLocation((int)point.getX(),(int)point.getY());
               transferable = new TransferableTreePath( path );
              source.startDrag(gestureEvent,DragSource.DefaultMoveNoDrop, transferable, this);
              System.out.println("Drag Gesture Recognized method over");
         }

    you're most welcome, Jon, and it's this board, which 'animates' me to do it that way and this way, and find out the differences..
    but, indeed: the 'settings' of a photo should be 'accessible' in both ways..
    ' cause, in MY workflow in iMHD6 or FCE, I FIRST import the video, and more important: the audio-track, which I 'spice up' with additional footage, as stills...
    .. but I've never done that in iM08, which is for my projects still in 'experimental use'...- (I LOVE those picture settings, de-saturating clips etc....), I get used to the many audio-layers in FCE ...
    ... and: lately, tought some iMovie-beginners (a photographer and a print-designer), with zil background knowledge of any iMovie version, the first steps with iM08... they want to use it to 'glue' some impressions together, they shoot while doing their photo-jobs.. and they were very impressed and excited!... +sooooo easy+ ... yepp, the User Experience IS breathtaking, awesome, groundbraking

  • Flex 2:  Drag and Drop

    Hi,
    I need help or maybe I can get some advice. I have a TileList
    that gets populated by buttons. I am using HTTPService as my
    WebService. I have a component called Buttons.mxml, to use as
    itemRenderer for my TileListEx.mxml. Everything is good as far as
    displaying all my buttons onto my TileList. My problem is when
    doing Drag-and-Drop. Right now when I drag a button and drop it in
    to a different spot/location (inside my TileList), it moves the
    other buttons too at the same time. I cannot drop a single button
    onto an exact position without affecting the other buttons. Is
    there a way to when you do a drag and drop, it will drop the item
    onto exact position as to where you wanted to drop it in. I
    attached my sample code, maybe someone can help me and give me some
    advice onto how to fix my problem or maybe can tell me a better
    solution of doing this.
    Buttons.mxml
    <?xml version="1.0" encoding="utf-8"?>
    <mx:VBox xmlns:mx="
    http://www.adobe.com/2006/mxml"
    horizontalAlign="center" verticalGap="0" horizontalGap="0" >
    <mx:Button label="{data.name}" width="100" height="50"
    textAlign="center" />
    </mx:VBox>
    TileListEx.mxml
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    xmlns:local="*" layout="absolute" backgroundAlpha="0"
    creationComplete="itemRequest.send()">
    <mx:HTTPService id="itemRequest"
    url="C:/TestFlex/menuitem.xml" useProxy="false" />
    <mx:VBox x="10" y="41" width="1000" height="550">
    <mx:Panel width="575" height="550" layout="absolute"
    id="menuItm" title="Fruits">
    <mx:TileList direction="vertical"
    dataProvider="{itemRequest.lastResult.menuitem.items.item}"
    height="100%" width="100%"
    itemRenderer="Buttons" rowHeight="60" columnWidth="110"
    dragEnabled="true" dropEnabled="true" dragMoveEnabled="true"
    dragEnter="true"/>
    </mx:Panel>
    </mx:VBox>
    </mx:Application>
    My menuitem.mxml
    <?xml version="1.0" encoding="Utf-8" ?>
    <menuitem>
    <items><item><name>Combo Chz
    Burg</name></item>
    <item><name>Burger</name></item>
    <item><name>Cheese
    Burger</name></item>
    <item><name>Bac Chz
    Burger</name></item>
    <item><name>Lumberjack</name></item>
    <item><name>Boomer
    Burger</name></item>
    <item><name></name></item>
    <item><name></name></item>
    <item><name>Double
    Play</name></item>
    <item><name></name></item>
    <item><name>No Roll</name></item>
    <item><name></name></item>
    <item><name>Well Done</name></item>
    <item><name>Rare</name></item>
    <item><name></name></item>
    <item><name></name></item>
    <item><name>Sausage</name></item>
    <item><name>Pulled
    Pork</name></item>
    <item><name>Grilled
    Cheese</name></item>
    <item><name></name></item>
    <item><name>Chicken
    Little</name></item>
    <item><name>King of
    Klubs</name></item>
    <item><name></name></item>
    <item><name></name></item>
    <item><name>Do It To
    It</name></item>
    <item><name>Sub</name></item>
    <item><name></name></item>
    <item><name>Hot Drink</name></item>
    <item><name>Bottle
    Water</name></item>
    <item><name>Soda</name></item>
    <item><name></name></item>
    <item><name></name></item>
    <item><name>Open Food</name></item>
    <item><name>Eat In</name></item>
    <item><name>Take Out</name></item>
    <item><name>Phone
    Order</name></item>
    <item><name>Extra</name></item>
    <item><name>Orange</name></item>
    <item><name></name></item>
    <item><name></name></item></items>
    </menuitem>
    Thank you very much in advance.
    -alfie

    When working with drag and drop, troubleshoot starting with
    the most obvious: Where exactly is the Canvas you're dropping onto
    and how large is it. Give the Canvas a temporary red background
    (myCanvas.setStyle("backgroundColor", "#FF0000")) to see exactly
    where it is on the stage. If you can't see it after you've changed
    the background color, chances are you can't drop anything onto it
    either.
    Glancing over your code I see a couple things:
    1. In DesignCanvas, you don't define the dropTarget variable,
    which is supposed to be a reference to the DesignCanvas.
    private function doDragEnter(event:DragEvent):void
    var dropTarget:Canvas = this;
    DragManager.acceptDragDrop(dropTarget);
    2. Your override of updateDisplayList() doesn't include
    super.updateDisplayList(unscaledWidth, unscaledHeight);
    I'd comment out your complete updateDisplayList() override
    and troubleshoot the drop target first, then you can start adding
    the other functionality and see if it works as you'd like.
    P.S. Just as a best practice, start your classes with
    uppercase and variables and functions lowercase, so DesignCanvas,
    not designCanvas.
    TS

  • How can I learn "Drag and Drop" with Swing components?

    Hello,
    Im using swing components, so using paint() to draw a "drag icon" doesnt seem acceptable. Im basically trying to move a JPanel image to be dragged/dropped over another JPanel in the same program/applet.
    I looked at Sun's Java Tutorial for information on doing drag and drop, but there was no trail completed yet.
    Does anyone know of any good resources to learn? Or can at least give me a general idea of how to do drag and drop?

    Did you see this?
    http://java.sun.com/docs/books/tutorial/dnd/index.html
    http://java.sun.com/docs/books/tutorial/reallybigindex.html

Maybe you are looking for

  • How to connect a printer with Remote Desktop for Mac, version 8

    Hello, I use Microsoft Remote Desktop 8.0.3 with my Mac to connect to an application which is based on a Windows Server 2008. I don't find the way to print to my Mac. I don't find the menu for it :-( Same problem to transfert a file from the Windows

  • Purchase Requsition is not closing automatically During ME59 PO creation

    Hi, We are using PO creation through ME59, In ME59 we have set the indicator 1 Set reqs. to "closed" In PR we have 1 qty and in PO was created for 1 qty. But the PR was not closed. When we check the F1 help for the filed it say it will work with resp

  • Urgent Problem in Report Dev 2000

    hi I have called a report in the following way com:='R30CLI32 server=repserver      report='||store_var||'\reports\NOTDONE.rdf userid='||user||'/'||pass||                ' destype=file desname='||store_var1||'\'||:global.vc_comp_code||:global.module_

  • One commercial app on several iPads

    Hi everyone, I would like to know your point of view in order to deploy a commercial app (from app store) on about thirty iPad. The problematics is : How can I deploy an app and deploy it on 30 iPad ? Do I need to purchase 30 apps ? I studied two cas

  • Sql Queries - adding calculated variables to views

    Hello: I'm trying to do add a calculated variable to my view that isn't an Entity Attribute, its simple really but i don't know if I'm leaving something out or not. I add the "new Attribute" , call it nCompleted, type - number I then check off everyt