Open a File in a JTextPane via Drag and Drop

Hi,
     I have a simple JTextPane in a Swing App on Windows XP. I would like to know if it is possible for me to be able to add the functionality such that I can drag a text file to the JTextPane and it would open the file inside the Pane. Is this possible? If yes then how do I implement it? (I am not insisting on the app working on non-Win XP systems � so portability is not a concern.)
     I have tried to search for the drag and drop stuff but I am confused. First, which interfaces should I implement i.e. DragGestureListener, DragSourceListener, DropTargetListener or what?
     I would be grateful for any pointers.
Thanks a lot,
O.O.

1. http://java.sun.com/docs/books/tutorial/uiswing/dnd/intro.html - This link did have the information but has since been updated and no longer points to the relevant information that I have since used.
So you where given a link with the appropriate informaton, but Sun has changed the information and you are blaming us for not helping? Unbelievable!
Here is a link to the old tutorial:
https://www.cs.auckland.ac.nz/references/java/java1.5/tutorial/uiswing/dnd/intro.html#importFiles
Now tell us how that does not do exactly what you wanted?
I really don�t know why some people waste their time here just providing you with linksBecause most people like yourself don't know how to ask a question. DnD is a complex topic. The only way to learn it is to read a tutorial and experiment. What a better way to learn than to play with a working example. You are given many working examples in the tutorial.
You did not state wihich example you had changed. You did not state what problems you where having.
The best you could state was "I'm confused". You where asked to clarify your problem/confusion but didn't. We are not mind readers so we couldn't provide further help.
I agree I am wasting my time helping someone who doesn't even appreciate the effort made by the many individuals of the forum and I won't make that mistake again.

Similar Messages

  • Can I move my very large iPhoto app and photos from main HD to a larger secondary HD via drag and drop?

    Can I move my very large iPhoto app and photos from main HD to a larger secondary HD via drag and drop?

    Welcome to the Apple Discussions.
    1. Quit iPhoto
    2. Copy the iPhoto Library from your Pictures Folder to the External Disk.
    3. Hold down the option (or alt) key while launching iPhoto. From the resulting menu select 'Choose Library' and navigate to the new location. From that point on this will be the default location of your library.
    4. Test the library and when you're sure all is well, trash the one on your internal HD to free up space.
    Regards
    TD

  • File Upload via Drag and Drop in IE10

    The drag-and-drop file upload feature introduced in Spaces PS5 is great but it is not compatible with IE9 and earlier versions (see link below).
    Has anyone tried using drag-and-drop with IE10? Did it work?
    https://support.oracle.com/epmos/faces/ui/km/SearchDocDisplay.jspx?_afrLoop=1753102566545647&type=DOCUMENT&id=1453326.1&displayIndex=1&_afrWindowMode=0&_adf.ctrl-state=nyed5wpzc_584

    I'm using the Windows version of Acrobat Pro 9 and found this thread with the same problem. (Key command to replace on Windows is: Ctrl + Alt).
    Anyway, to answer the how to disable the warning, go to the Acrobat Preferences. In the General category under "Warnings", check the setting "Do not show edit warnings". There should be a similar setting on the Mac version.
    (Now I wish replacing pages didn't require a key command like in previous versions.)

  • Unable to send or recieve images via drag and drop?

    I am unable to send or recieve jpg and gif images by dragging and dropping from finder. How do I fix this?

    Hi,
    Where are you dragging them to ?
    You Can do it two ways using Drag.
    One is to the Buddy's Name in the Buddy list and letting go  (it gets sent as a loose file)
    The Second is to drag it to the Text field during a Text chat (Excluding Group Chats)
    The First causes an Invite to accept to pop up on the Buddies Screen.
    You can also see see when it is Accepted (you may even have to confirm sending depending on your Settings)
    The Second gets sent as a File Link in the Chat which the Buddy has to Also Accept...
    You can also send files by highlighting a Buddy and going the the Buddies Menu > Send File.
    This method tends to point to error with the File Transfer port not being open.
    So...
    Check you can send Files first by all three methods.  (these tends to ignore  Firewall and Router settings as it is Outgoing)
    Get your Buddy to Send by all three methods.
    IF this is AIM and you are having issues log out of the Account  (IChat > Preferences > Accounts > Account Info Tab (Deselect "Use this Account")
    Now go to the Sever Settings
    Change the Default port from 5190 to 443.
    iChat Logs in on port 5190 using the TCP Protocol.
    File Transfers or Direct IMs when done in a Chat are sent on Port 5190 but on the UDP Protocol (It is Peer-to-Peer).
    Some Router don't like this dual Use.
    If you still have issues then you will need to either Enable the Firewall and check iChat in in the List of allowed Apps and/or open  port 5190 in you router. (on the UDP Protocol if stated)
    10:22 PM      Wednesday; September 28, 2011
    Please, if posting Logs, do not post any Log info after the line "Binary Images for iChat"
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb( 10.6.8)
     Mac OS X (10.6.8),
    "Limit the Logs to the Bits above Binary Images."  No, Seriously

  • Safari Bookmarks Lost via Drag and Drop to Finder

    All of my most important bookmarks vanished without a trace after I dragged and dropped their folder from the "Show All Bookmarks" screen in Safari 4.0.3 to a Shared Network Drive in the Finder sidebar. The Shared Network Drive was not connected at the time (I hadn't realized), but I received no error message that the bookmarks could not be copied to the destination--the folder and its contents were simply gone. I've scoured all drives for the bookmark files with no luck, and I confirmed that dragging other files (not bookmarks) to the disconnected Shared Network Drive gives an error message and no change to file locations.
    Admittedly, this particular situation is somewhat rare, but it seems like a kind of shoddy black hole in the software: no alerts, no trash bin, no bookmark files to be found.
    Obviously this is a perfect example of why one should backup bookmarks via Time Machine, MobileMe, etc.--but I really just want to understand the problem, and to see it resolved if necessary. Any ideas? Similar experiences?
    Thanks for reading!

    Thanks very much for your reply, Carolyn.
    I tried a Spotlight search as you suggested, but found no file called "Safari Bookmarks.html," and nothing with a similar name. Would that be some kind of master log of my Safari bookmarks?
    I'm looking everywhere for an alternate record of those web addresses (router, cache, cookies, Google), but unfortunately I empty my Safari history regularly and nothing else has panned out so far.

  • Embed animate file in Dreamweaver, make the drag and drop stop working

    The drag and drop works fine when I open the Animate file, but when I embed it using the "Media > Edge Animate", it does not work. How can I solve this problem?
    I'm using an external js file.
    Thanks.

    Need you to share the dreamweaver project along with the edge animation, to check the issue.
    Regards,
    Vivekuma

  • IPhoto '09 8.1.2 Doesn't import via drag and drop!

    My Macbook Pro version of iPhoto won't allow me to drag & drop photos into the albums. It will allow import via menu but only as new events and then still won't allow me to add to existing albums. I have tried reinstalling OS as I had another problem with moving files across the network, it allowed copy but not move. When the photo is chosen I then drag into the correct album. It shows the green cross but doesn't allow the drop. It also doesn't let go of the file so the the photo is attached to the cursor until I force quit on iphoto.
    Anyone got any ideas please as I really use iphoto to push my files around my network & devices.
    Thanks
    Pete

    Read through this:
    http://www.switchingtomac.com/tutorials/osx/cant-drag-and-drop-in-os-x-lion/
    Test in another User account. Try booting into Safe Mode:
    http://support.apple.com/kb/HT1455
    If you don't maintain a current backup, I guarantee you will lose ALL of your data, not some...ALL.

  • Cannot move photos via drag and drop (library grid view)

    I've seen several adobe tutorials and youtube videos that show moving photos or folders by drag and drop in the library grid view.  I cannot get it to work.
    Steps:
    1. Mousedown on a photo (not the frame) in the grid
    2. Drag the mouse to a folder in the "Folder" pane (left of the grid)
    3. Mouseup on the destination folder
    Results:
    Nothing happens.  The mouse cursor doesn't change from the arrow.  There is no indication I can drag and drop.  The photos are not moved.
    The photos are stored on a NAS.  Of course I can move them around via Windows Explorer, but I want to do this from inside LR4 for obvious reasons.  From LR4, I can create new folders, but I still cannot move photos into those folders.  I also tried creating a new folder on a local drive.  Again, I was able to create the folders, but was not able to move any photos into the folder.
    What else can I do to toubleshoot this issue?

    I created a new catalog.  Imported a folder on my C drive, created a subfolder, and successfully moved photos into the subfolder.
    I tried the same steps in my original catalog and now I can move all photos (including those on my NAS).  I've been at this for 3 hours.  I have no clue why it is working now, but I guess I'm happy.  Now, it shows the stack of photos when I try to drag and drop.
    I even reverted to my original preferences file (that I backed up before deleting) and I'm still able to move the files.  Really strange.

  • Can't Replace Pages (via drag and drop in Pages panel) in Acrobat 9 Pro

    I'm running OS X 10.5.8, Acrobat Pro 9.1.3, PPC G5 PowerMac.
    I'll have two PDFs open and I'll want to replace certain pages from document A with certain pages from document B.  Rather than using the Replace Pages command from the Document menu, I prefer to visually see what I'm changing.  For this reason I've always preferred the drag and drop method, where one selects a page thumbnail from one document and drops it onto a page thumbnail in another document. This only seems to be a problem in Acrobat 9.  This works fine in Acrobat 7.1.1 and 8.1.6.  Drag and drop will allow one to insert pages but the replacement of pages is not working.  As described in Acrobat Help, under "Replace pages using a page thumbnail," I try to drop the page thumbnail onto the page number as prescribed but the page to be replaced never highlights like it should.  It will only give the insertion highlight between each page, indicating that it is about to insert a page.
    Other macs exhibit the same behavior -- it always works in Acrobat 7 and 8 but not 9.
    Thank you for your assistance.

    I'm using the Windows version of Acrobat Pro 9 and found this thread with the same problem. (Key command to replace on Windows is: Ctrl + Alt).
    Anyway, to answer the how to disable the warning, go to the Acrobat Preferences. In the General category under "Warnings", check the setting "Do not show edit warnings". There should be a similar setting on the Mac version.
    (Now I wish replacing pages didn't require a key command like in previous versions.)

  • Combine Files Dialog 8.1.6--drag and drop broken?

    I just reinstalled Acrobat 8, and the Combine Files panel is "all whacky".
    If I drag one or more documents into the panel, they are added normally. But if I then add another batch of 1 or documents, the FIRST SET OF DOCUMENTS is added again.
    To be clear, if I drag documents 1.tif, 2.tif, and 3.tif into the Combine Files panel, I end up with (as expected)
    1.tif
    2.tif
    3.tif
    But if I then drag documents 4.tif and 5.tif into the panel (or any other set of documents), I end up with
    1.tif
    2.tif
    3.tif
    1.tif
    2.tif
    3.tif
    Adding files through the file chooser panel works fine. Can someone tell me if this is peculiar to my installation or if it is a bug in Acrobat Pro 8.1.6?
    Thx

    Sort of the same here:
    I just noticed that the standard "drag and drop" in combination with "cmd + tab" to switch applications no longer works on my MacBook Pro. Whenever I try to drag pictures (e. g. jpg) from Safari into a Keynote 09 presentation (switching from Safari to Keynote using "cmd + tab"), the dragged image simply hangs and cannot be dropped into Keynote.
    And here's the _truly weird_ thing:
    When I then use "cmd + tab" again to switch to the next app again, the Keynote window stays on top and I can suddenly move and drop the dragged picture again. How strange is that?

  • 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

  • IPhoto file creation date inconsistencies during drag and drop

    I have noticed that if I drag and drop a photo from iPhoto to Finder, the file creation dates in Finder are inconsistent.
    (This question is related to drag and drop only and not File->Export, which always uses the export date and timestamp for the file creation date and thus does not suit my needs).
    TEST A -- If the EXIF DateTimeOriginated is 01/01/2013, and today's date is 03/03/2013, then:
    In some cases when I drag a file to Finder, the EXIF date is used as the file modification/creation date in Finder
    In some cases, today's date is used as the file modification/creation date in Finder
    In some cases, a date in between the EXIF date and today's date is used
    It appears that for case A1, these are files that do not have a modified copy.  That is, if you select the photo in iPhoto and then click "File" -> "Reveal In Finder", the "Modified File" choice will be greyed out.
    For cases A2 & A3, iPhoto has inexplicably decided to create modified versions of these files either today or sometime in the past.
    TEST B -- I have read that unexplained modifications are tied to the auto-rotate function in cameras, and it does seem to be the case when I performed the test below:
    Select a large group of landscape format photos (these would not have been auto-rotated), then drag and drop to Finder.  The file creation dates are set to the EXIF date
    Add some portrait photos to the group in (1).  Now the file creation date of ALL photos including the non auto-rotated photos are set to the current date
    The behaviour in B2 is clearly wrong, since the landscape photos should be the same as in B1.  This is bug #1.
    Furthermore, iPhoto appears to be inconsistent with when these modifications are made.  For example, I dragged & dropped an auto-rotated photo on 02/02/2013, then dragged & dropped it again today, then the file creation date in Finder (and also the date of the modified file in iPhoto, as shown in iPhoto File->Reveal In Finder->Modified File) can either the EXIF date (01/01/2013), the late of the last drag & drop (02/02/2013), or today's date (03/03/2013); there does not appear to be any rhyme or reason to this.  This is bug #2.
    In any case, saying "you should never use drag & drop in iPhoto" (as I have read in some other forum posts) isn't a solution, because Apple should either (a) support this function correctly or (b) remove it altogether.  Furthermore, I regularly burn photos to disk for others so having the file date and timestamps correctly set to the EXIF date helps keeping the photos sorted in the directory listings for multiple OS, so File->Export isn't a solution.

    File data is file data. Exif is photo data. A file is not a photo.  It's a container for a photo.
    When you export you're not exporting a file. You're exporting a Photo. The medium of export is a new file. That file is created at the time of export, so that's its creation date. The Photo within that file is dated by the Exif.
    There are apps that will modify the file date to match the Exif.
    The variation you're seeing is likely due to the changes in how the iPhoto library works over the past few versions. Drag and drop is handy, but is not a substitute for exporting, nor intended to be.

  • ITunes 11.0.4 still copying files to media library after dragging and dropping while holding down "option"

    I'm having trouble adding media without automatically copying the file to the iTunes media libary after dragging and dropping while holding down "option."
    In Preferences > Advanced, "Copy files to iTunes media folder when adding to library" is checked. When I drag a file into iTunes while holding "option", the green "plus" icon disappears. However, iTunes still copies the file to media folder.
    Any suggestions?

    you can also try:
    I found that if I SCROLL down to the word 'playlist' and hover around the name, a 'show' comes up.  Click on the 'show' and everything magically appears.

  • Help with selecting files from script menu or drag and drop

    I found this scale images applescript online. It works great when a bunch of files is dragged on top of the script but I would like it to also work when a folder or group of files is selected in the Finder and I activate it from the scripts menu.
    I can't get my on run statement to work. I'm not really an Applescript guy so I'm really just asking if someone can help finish what I started in this on run.
    -- save in Script Editor as Application
    -- drag files to its icon in Finder
    property target_width : 120
    property save_folder : ""
    on run
    tell application "Finder"
    activate
    set folder_path to quoted form of (POSIX path of (the selection as alias))
    set theItems to every file of folder_path
    end tell
    end run
    on open some_items
    -- do some set up
    tell application "Finder"
    -- get the target width, the default answer is the property target_width
    set new_width to text returned of ¬
    (display dialog "Target width:" default answer target_width ¬
    buttons {"OK"} default button "OK")
    if new_width as integer > 0 then
    set target_width to new_width
    end if
    -- if the save_folder property has not been set,
    -- set it to the folder containing the original image
    if save_folder is "" then
    set save_folder to ¬
    (container of file (item 1 of some_items) as string)
    end if
    -- get the folder to save the scaled images in,
    -- default folder is the property save_folder
    set temp_folder to ¬
    choose folder with prompt ¬
    "Save scaled images in:" default location alias save_folder
    set save_folder to temp_folder as string
    end tell
    -- loop through the images, scale them and save them
    repeat with this_item in some_items
    try
    rescaleand_save(thisitem)
    end try
    end repeat
    tell application "Image Events" to quit
    end open
    on rescaleand_save(thisitem)
    tell application "Finder"
    set new_item to save_folder & "scaled." & (name of this_item)
    end tell
    tell application "Image Events"
    launch
    -- open the image file
    set this_image to open this_item
    set typ to this_image's file type
    copy dimensions of this_image to {current_width, current_height}
    scale this_image by factor (target_width / current_width)
    save this_image in new_item as typ
    end tell
    end rescaleandsave

    When items are dragged to your script's icon they are passed in to the on open handler, so this triggers:
    on open some_items
    and the dragged items are passed in as some_items
    In contrast, when you double-click on the script, or invoke it via the Script menu, this runs the on run handler:
    on run
      tell application "Finder"
        activate
        folder_path to quoted form of (POSIX path of (the selection as alias))
        set theItems to every file of folder_path
      end tell
    end run
    However, there's nothing in this block that actually does anything with the selection - you (dangerously) assume that the selection is a folder (you really should check first), and just set theItems to every file in that folder then you exit.
    So to do what you want you'll need to edit your run handler to filter the selection and pass files over to the code that does the hard work.
    You already have the basis for this - your rescaleandsave() handler, so it's just a matter of identifying the files in the selection and passing those over to that handler:
    on run
      tell application "Finder"
        set cur_selection to (get selection) -- get the selection
        repeat with each_item in cur_selection -- iterate through
          if class of each_item is folder then -- do we have a folder?
            set theFiles to every file of each_item -- if so, get its contents
            repeat with each_file in theFiles -- iterate through them
              my rescaleand_save(eachfile) -- and process them
            end repeat
          else if class of each_item is document file then -- do we have a file selected?
            my rescaleand_save(eachitem) -- if so, process it
          end if
        end repeat
      end tell
    end run
    So the idea here is that the run handler gets the selection and works through the (potentially-numerous) items. For each selected item it checks whether its a folder or a file, if its a folder it gets all the files within and passes them to the rescaleandsave handler.
    Note that this is not recursive - it won't catch files within folders within folders - since it only looks at the top level of selected folders, but it wouldn't be hard to rework the script to handle that if that's what you need.

  • Fast transfers via drag and drop w/ARD, but painfully slow on AFP...?

    So, we've tested this using the same exact file on the same machine (same internet connection and all that):
    If I open up ARD and then control our server with it via my laptop, then I open up my personal afp folder on the server itself via ARD and take a file from my laptop and drag it over to the server folder using ARD, it transfers fast.
    Now, If I try it the 'conventional' way (without ARD open at all) and just go the command+k (or "connect to server") route and try to drag the same file over the the same folder as before, it will take at LEAST 10 times as long, if not more.
    Can anyone explain why this may be occurring? Clearly, it's not the network since transferring a file the first was was lightning fast. So, it's got to be something either on my machine or on the server that the afp folder is hosted on that's choking up with connection somehow.
    Any thoughts?

    I've read somewhere, that ard uses multicasting for distribution of files.

Maybe you are looking for