Drag and drop images from the OS or select images over filebrowser

Hello,
I want to create an image upload tool in JavaFX with similar functionality like Jumploader (http://jumploader.com/). The users should be able to select images from the filesystem that will be resized and uploaded to their website, similar as in Facebook. The difference is that I want users to be able to crop images directly in my application. This is something, other upload tools do not offer.
I was searching weeks on the web trying to find a sample on how to drag and drop images in to a JavaFX 1.3.1 app or also to create a file browser. I have found many examples but they seem to be outdated. Is it to early yet to try and start projects like these with JavaFX as JavaFX is still under development? Or can anybody lead me in to the right direction?
Thanks,
Chris

To be more precise, you can setup a JComponent or JPanel on top of your JavaFX nodes that has a TransferHandler that can convert the (AWT/Swing) images dragged to the app to JavaFX image and then insert it into the underlying node.
As for the file chooser itselft: ListView and the JavaFX composer can allow you to create one quite easily. TreeView can aslso be used to a lesser extend (still a big buggy). For both of these, there are small bugs in the Cell API that may (or may not) prevent from displaying a proper thumbnail in the cells.
You can also use a regular JFileChooser if you do not mind the dialog box having a different LnF from the rest of your application.

Similar Messages

  • I used to be able to copy or drag and drop links from the address window. Now with the update, only the address is copied or dragged not the link. (Says something about not giving site information). I want to be able to drag and drop or copy links.

    Question
    I used to be able to copy or drag and drop links from the address window. Now with the update, only the address is copied or dragged not the link. (Says something about not giving site information). I want to be able to drag and drop or copy links.

    To be more precise, you can setup a JComponent or JPanel on top of your JavaFX nodes that has a TransferHandler that can convert the (AWT/Swing) images dragged to the app to JavaFX image and then insert it into the underlying node.
    As for the file chooser itselft: ListView and the JavaFX composer can allow you to create one quite easily. TreeView can aslso be used to a lesser extend (still a big buggy). For both of these, there are small bugs in the Cell API that may (or may not) prevent from displaying a proper thumbnail in the cells.
    You can also use a regular JFileChooser if you do not mind the dialog box having a different LnF from the rest of your application.

  • HT5934 My iMac won't let me drag, and drop anything from the desktop to other files on the desktop, or anywhere else.

    My iMac won't let me drag, and drop anything from the desktop to other files on the desktop, or anywhere else.

    This procedure is a diagnostic test. It makes no changes to your data.
    Please triple-click anywhere in the line below on this page to select it:
    ls -@Oaen | pbcopy
    Copy the selected text to the Clipboard by pressing the key combination command-C.
    Launch the built-in Terminal application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ Open LaunchPad. Click Utilities, then Terminal in the icon grid.
    Paste into the Terminal window by pressing the key combination command-V. I've tested these instructions only with the Safari web browser. If you use another browser, you may have to press the return key after pasting.
    Wait for a new line ending in a dollar sign ($) to appear below what you entered.
    The output of the command will be automatically copied to the Clipboard. If the command produced no output, the Clipboard will be empty. Paste into a reply to this message.
    The Terminal window doesn't show the output. Please don't copy anything from there.
    If any personal information appears in the output, anonymize before posting, but don’t remove the context.

  • I reinstalled Lion and now I cannot drag and drop photos from the internet to my desktop

    My Macbookpro was giving me a startup disk full message so I emptied out my photo library and itunes library to an external drive. By then I think the damage was done because I was still encountering the spinning color wheel all the time. On the advice of he Genius bar I reinstalled Lion. It worked well except for this one glitch. I can no longer drag and drop photos from the internet. Any ideas are appreciated. Thanks.

    That sounds like a browser issue so what browser and what web sites?

  • Listening to Drag and Drop event from the extension panel

    How is it possible to detect a drop event from a Layer to a text field in a panel developer using the SDK?
    Drag and drop operation between panel elements are not the issues, but drag and drop from Photoshop and the panel might be an issue.
    Is it possible to implement them?
    If yes, could I be redirected to the documentation topic or can someone post some code snippet ?
    Thanks

    What model of camcorder is your video from and what resolution is it?
    What operating system are you using? Have you ensured that you have the latest version of Quicktime, per the program's requirements?
    Do not convert your video. The program will best with video directly from a camcorder, and converting it may will turn it into a format that it may be LESS likely to work well with.

  • I have an iPod nano which s loaded with music from a pc. My wife is trying to put the music from the nano onto her Mac laptop. It will not allow her to drag and drop music from the nano to iTunes. How can we get the music from the nano onto her mac laptop

    can someone please tell me if it is possible to get music off a nano (loaded from a pc) and into iTunes on a mac laptop ?

    You're dealing with two different Apple ID's so that won't work and according to Apple, they cannot be consolidated.
    Frequently Asked Questions About Apple ID

  • Drag and drop icons from onside of the split pane to the other side.

    Hello All,
    I am tring to write a program where i can drag and drop icons from the left side of the split pane to the right side. I have to draw a network on the right side of the split pane from the icons provided on the left side. Putting the icons on the labels donot work as i would like to drag multiple icons from the left side and drop them on the right side. CAn anyone please help me with this.
    Thanks in advance
    smitha

    The other option besides the drag_n_drop support
    http://java.sun.com/docs/books/tutorial/uiswing/dnd/intro.htmlis to make up something on your own. You could use a glasspane (see JRootPane api for overview) as mentioned in the tutorial.
    Here's another variation using an OverlayLayout. One advantage of this approach is that you can localize the overlay component and avoid some work.
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.image.BufferedImage;
    import java.io.*;
    import javax.imageio.ImageIO;
    import javax.swing.*;
    import javax.swing.event.MouseInputAdapter;
    public class DragRx extends JComponent {
        JPanel rightComponent;
        BufferedImage image;
        Point loc = new Point();
        protected void paintComponent(Graphics g) {
            Graphics2D g2 = (Graphics2D)g;
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                                RenderingHints.VALUE_ANTIALIAS_ON);
            if(image != null)
                g2.drawImage(image, loc.x, loc.y, this);
        public void setImage(BufferedImage image) {
            this.image = image;
            repaint();
        public void moveImage(int x, int y) {
            loc.setLocation(x, y);
            repaint();
        public void dropImage(Point p) {
            int w = image.getWidth();
            int h = image.getHeight();
            p = SwingUtilities.convertPoint(this, p, rightComponent);
            JLabel label = new JLabel(new ImageIcon(image));
            rightComponent.add(label);
            label.setBounds(p.x, p.y, w, h);
            setImage(null);
        private JPanel getContent(BufferedImage[] images) {
            JSplitPane splitPane = new JSplitPane();
            splitPane.setLeftComponent(getLeftComponent(images));
            splitPane.setRightComponent(getRightComponent());
            splitPane.setResizeWeight(0.5);
            splitPane.setDividerLocation(225);
            JPanel panel = new JPanel();
            OverlayLayout overlay = new OverlayLayout(panel);
            panel.setLayout(overlay);
            panel.add(this);
            panel.add(splitPane);
            return panel;
        private JPanel getLeftComponent(BufferedImage[] images) {
            JPanel panel = new JPanel(new GridBagLayout());
            GridBagConstraints gbc = new GridBagConstraints();
            gbc.weightx = 1.0;
            gbc.weighty = 1.0;
            for(int j = 0; j < images.length; j++) {
                gbc.gridwidth = (j%2 == 0) ? GridBagConstraints.RELATIVE
                                           : GridBagConstraints.REMAINDER;
                panel.add(new JLabel(new ImageIcon(images[j])), gbc);
            CopyDragHandler handler = new CopyDragHandler(panel, this);
            panel.addMouseListener(handler);
            panel.addMouseMotionListener(handler);
            return panel;
        private JPanel getRightComponent() {
            rightComponent = new JPanel(null);
            MouseInputAdapter mia = new MouseInputAdapter() {
                Component selectedComponent;
                Point offset = new Point();
                boolean dragging = false;
                public void mousePressed(MouseEvent e) {
                    Point p = e.getPoint();
                    for(Component c : rightComponent.getComponents()) {
                        Rectangle r = c.getBounds();
                        if(r.contains(p)) {
                            selectedComponent = c;
                            offset.x = p.x - r.x;
                            offset.y = p.y - r.y;
                            dragging = true;
                            break;
                public void mouseReleased(MouseEvent e) {
                    dragging = false;
                public void mouseDragged(MouseEvent e) {
                    if(dragging) {
                        int x = e.getX() - offset.x;
                        int y = e.getY() - offset.y;
                        selectedComponent.setLocation(x,y);
            rightComponent.addMouseListener(mia);
            rightComponent.addMouseMotionListener(mia);
            return rightComponent;
        public static void main(String[] args) throws IOException {
            String[] ids = { "-c---", "--g--", "---h-", "----t" };
            BufferedImage[] images = new BufferedImage[ids.length];
            for(int j = 0; j < images.length; j++) {
                String path = "images/geek/geek" + ids[j] + ".gif";
                images[j] = ImageIO.read(new File(path));
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.add(new DragRx().getContent(images));
            f.setSize(500,400);
            f.setLocation(200,200);
            f.setVisible(true);
    class CopyDragHandler extends MouseInputAdapter {
        JComponent source;
        DragRx target;
        JLabel selectedLabel;
        Point start;
        Point offset = new Point();
        boolean dragging = false;
        final int MIN_DIST = 5;
        public CopyDragHandler(JComponent c, DragRx dr) {
            source = c;
            target = dr;
        public void mousePressed(MouseEvent e) {
            Point p = e.getPoint();
            Component[] c = source.getComponents();
            for(int j = 0; j < c.length; j++) {
                Rectangle r = c[j].getBounds();
                if(r.contains(p) && c[j] instanceof JLabel) {
                    offset.x = p.x - r.x;
                    offset.y = p.y - r.y;
                    start = p;
                    selectedLabel = (JLabel)c[j];
                    break;
        public void mouseReleased(MouseEvent e) {
            if(dragging && selectedLabel != null) {
                int x = e.getX() - offset.x;
                int y = e.getY() - offset.y;
                target.dropImage(new Point(x,y));
            selectedLabel = null;
            dragging = false;
        public void mouseDragged(MouseEvent e) {
            Point p = e.getPoint();
            if(!dragging && selectedLabel != null
                         && p.distance(start) > MIN_DIST) {
                dragging = true;
                copyAndSend();
            if(dragging) {
                int x = p.x - offset.x;
                int y = p.y - offset.y;
                target.moveImage(x, y);
        private void copyAndSend() {
            ImageIcon icon = (ImageIcon)selectedLabel.getIcon();
            BufferedImage image = copy((BufferedImage)icon.getImage());
            target.setImage(image);
        private BufferedImage copy(BufferedImage src) {
            int w = src.getWidth();
            int h = src.getHeight();
            BufferedImage dst =
                source.getGraphicsConfiguration().createCompatibleImage(w,h);
            Graphics2D g2 = dst.createGraphics();
            g2.drawImage(src,0,0,source);
            g2.dispose();
            return dst;
    }geek images from
    http://java.sun.com/docs/books/tutorial/uiswing/examples/components/index.html

  • Really stupid that you can't drag and drop photos from Finder into Events

    There is no way in iPhoto to do what I want and need to to, to wit, drag and drop photos from the Finder into existing iPhoto Events.
    It really doesn't make sense that you can't do this. First of all, calling these groups Events to begin with is not smart; in my case, a group of photos in a folder on the Finder is rarely all from one photo session or so-called "event"--- instead of Events they should just be called Groups or something, and you should be able to drop individual photos into them. I have thousands of family photos that were accumulated on my hard drives over the years, some scanned in from film negatives, slides, or prints, others from digital cameras, and when I have changed Macs and hard drives over the years, every time a folder of photos was moved from an old hard drive to a new one, or regrouped into various folders, the photos seem to have acquired new dates of origin, etc.
    Anyway, what I mean is, if Events are all time based, then somebody like me who has thousands of photos with all sorts of dates of origin, mostly unrelated to the date that the photo was actually shot, is screwed. I have old photos with new dates of origin and other mismatches between photos and the dates when they were actually shot or scanned.
    My gripe is, again, that when I find photos on my hard drives that belong in certain iPhoto Events that have already been created, I cannot just drag these photos from the Finder and drop them into the Events they belong in. Instead, the stupid program creates a new Event from each photo I try to drop into an existing Event. That means I have to chase these new photos all over the place inside of iPhoto, trying to figure out where each new photo (now called an "Event") has ended up, so that I can drag and merge it into the Event I wanted it to go into in the first place. A real pain in the neck. It simply takes too long to do this for each photo added.
    What this means is that iPhoto is not going to be a practical way to organize for a person like me until Apple makes it possible to simply drop any photo from the Finder into an existing Event. There should be an option to allow that. I'm really surprised there is not one. <edited out by Hosts>
    Tom

    Tom, iPhoto will not overwrite photos with the same name. I have plenty of photos with the same name in the same event. Each photo most likely has an internal handler that manages the photo, and not just the name of the file.
    I agree with you that this is sub-optimal, and (IMO) I think what happened is iPhoto 6 had rolls, and they came up with a really cool interface for mousing over those rolls, and decided it was more consumer friendly (and because film is a thing of the past) to call them events, rather than rolls. I think it was worth a shot, but they just slightly missed.
    Right now in iPhoto08, any serious organization is done in folders and albums. Personally, I think they need to combine the two concepts -- the great "mouse over" view of events with the organization abilities of folders and albums. I'd like an albums view where I can mouse over the albums. Actually, Aperture 2's interface for organization is more functional than iPhoto, so I am hoping some of that benefit creeps into the next iPhoto release.
    What I do is: I use events for high level grouping (like Winter 2007) and I organize folders and albums to break that down further ("trip to Montreal" "Christmas" etc.). But I do it backwards. I fill albums first, then I organize events.
    When I drag in pictures to iPhoto, first I make the target album in iPhoto that I want to populate, then I drag the photo directly to that album (not to events). iPhoto automatically puts the photo into the album I created and also into a new event. Later, I go into events, right-click on this new event to "open event in separate window" then I move around the events view, to drop in the pictures from the "import" event I just created. If I move all the pictures into other events, iPhoto automatically deletes the event I just emptied. You could skip the event organization all together if you wanted to, but you'd lose the cool mouse-over feature, which can be handy.
    One nice thing about having events AND albums is you can have the photo just once in iPhoto, in an event, but then have the photo appear in as many albums as you want (as well as projects and web galleries) all while only having one photo on your hard drive. So, there are benefits to events, but I think iPhoto is missing just a couple little bits of organizational ability to make it perfect. (and yes, I've submitted this all to Apple as feature requests)
    Just in case you don't know -- events don't have any hierarchy. That is, you can't nest events. But you can have folders with subfolders, and any folder can contain albums. Albums cannot have sub-albums, and folders don't hold photos. Only albums hold photos, and folders (or sub-folders) hold albums. Try create some folders and albums and you'll get the hang of it. One other issue that Apple needs to address. When you create a new folder or album, it doesn't put it right where you want it, but rather puts it at the bottom of the list, so you have to drag it up to where you want it. Try it out, and you'll see what I mean, then submit it as a feature request to improve that.
    I agree it's not perfect, but it's not too bad once you get used to it. And the benefits of working with the rest of the features of iPhoto is worth it. I'm just really hoping they do a few tweaks on the next release. They are near greatness here. They could just use a little nudge on the last bits. (in my opinion of course. Others may disagree, but I've talked to enough people who have the same issues you are having to know we are not alone on this).

  • HT203128 I can't drag and drop music from iTunes 12 to iOS 8 iPhone 5s. How do I move music now?

    I connect the iPhone to itunes. that works. Everything shows up fine, but I can't drag and drop music from the 'music' section of iTunes 12 on my new mbp or my iMac. I used to be able to. Also, when I slide to delete songs on the iPhone, they still appear as 'ghosts' in the list on iTunes when the phone is connected - if I double click them, a exclamation mark in a circle comes up on the left of the track and it doesn't play. Can anyone help? Kind of need to get this sorted - it's bloody frustrating. I've restarted iPhone, iMac, MBP, downloaded the latest versions of iOS, OS X 10.10.3.

    you iphone does not work like a regular ipod, where you can drag and drop music, you must sync it with itunes. plug it into your computer, click on the icon that is labeled iphone. when you do this there is a section on the top that says music. click on that, then you can select playlists and artists, etc. then click apply. it should work then

  • I want to have two folders of Finder so that I can easily drag and drop files from one folder to another

    I have been trying to reorganize my files. When in Manila I created a folder called Manila 2015 in Documents. I have the Mother folder Files 2015 with several subfolders like Finances, Personal, Tax etc. I want to have two finder folders simultaneously so that I can drag and drop files from the Manila 2015 folder to the various subfolders in the mother folder Files 2015. I am not able to open two windows of Finder on the desktop.

    I have since found out that a new finder window can be opened witht the short cut Command+N.
    Thanks anyway.

  • I recently uploaded some pics and videos from an ipad and a camera. I put them all on Iphoto and backed them up in my personal folder. I then trimmed one of the videos and dragged and dropped that into the master folder(pictures). Its now gone!! HELP!?!?!

    I rencently added all my photo's from my Ipad and Camera. There were photos and videos on both. The import was done through Iphoto and then transfered to my backup in my pictures folder. I then took one of my videos and trimmed it and then addded that trimmed version to my back up(pictures)albumn. It asked If i wanted to replace existing photo or cancel and I hit replace. Now the file plays great on Iphoto but I am unable to share it through any form(facebook, Imessage etc) and in my back up(pictures) it says the file in only 87kb. I dragged and dropped it from Iphoto to the desk top along with another important video, when I hit get info on both of them one of them is a full sized video(50mb or whatever) and the other one(the one I am trying to recover) is only the 87kb. I want this full file avaiable to me how can I get it back?? it is already deleted off the camera??? please please help me.

    Garret,
    is your movie in your backup folder a Quicktime movie? Then probably only have the Quicktime wrapper in your backup folder, but not the referenced media in the file fork of the movie. If you see the full quality movie in iPhoto in QuickTime player, don't drag it from the browser to the Desktop, but use "File > Reveal in Finder > Original File" to show the movie in your iPhoto Library. Select the Movie when it is revealed and ctrl-click it to open it in Quicktime Player.
    Export it from Quicktime Player with "Export to" and share it to iTunes. This way it will be converted to a .mp4 movie that embeds the missing resources.
    You can drag the converted movie from iTunes to the Desktop or share it using to Media Browser to other applications.
    Regards
    Léonie

  • I was able to drag and drop songs from iTunes in to Garage Band so I could slow them down to learn how to play them. Since the newest version of iTunes came out I no longer can. Is this a feature that I can turn back on?

    I was able to drag and drop songs from iTunes in to Garage Band so I could slow them down to learn how to play them. Since the newest version of iTunes came out I no longer can. Is this a feature that I can turn back on? I really would like to continue to utlize that feature because it makes learning to play songs easier. Any help would be appericated.

    To import music into your iTunes library on the computer go to iTunes>Help>iTunes Help>Add items to iTunes and follow the instructions
    Delete the "songs" that do not play in your iTunes library and reimport them.

  • I can't remove icons from the dock, they don't move at all when I try to drag and drop them off the dock

    I can't remove icons from the dock, they don't move at all when I try to drag and drop them off the dock any help out there?

    Restart and see if that solves your issue.

  • Why can't I drag and drop music from a folder on my PC into my iTunes window?

        Why can't I drag and drop music from a folder on my PC into my iTunes window?
    I have not found any article that has answered this question. They have come up with things like open the side bar and it will work, or you are using wrong format of music. Now this all happened when I upgraded to iTunes 10 and has not worked since and it worked fine before. Music format is correct, I have even gone as far as copying a file already in iTunes and trying to add it again. As soon as the files enters the frame of iTunes the music files icon the pointer is carrying turns into a circle with a slash through it.
    ITunes Ver. is 11.1.5.5  Windows Ver. is Windows 8.1 Pro with Media Center
    Files I have tried adding are standard MP3, 256 kbps purchased AAC Audio file, MP3 converted by iTunes into a 256 or 320 kbps AAC Audio file. None can be draged and droped but all can added by going to File/Add File to Library...  or File/Add Folder to Library...
    Add items from your computer to your iTunes library
    Do either of the following:
    1. Drag a file or folder from the desktop to the iTunes window.If you add a folder, all the files it contains are added to your library.
    2. In iTunes, choose File > Add to Library, locate a file or folder, and click Open.
         I can add files and folders by doing number 2 above but can not doing number 1
    I have gone as far as uninstalling iTunes and reinstalling per apple procedures below.
    Steps
    1. Remove iTunes and its related components from the Control Panel
    Use the Control Panel to uninstall iTunes and related software components in the following order and restart your computer:
    iTunes
    Apple Software Update
    Apple Mobile Device Support
    Bonjour
    Apple Application Support (iTunes 9 or later)
    Important: Uninstalling these components in a different order or only uninstalling some of these components may have unintended effects.

    I had this problem on Windows 8.1.1 and iTunes 11.2.2.3
    To resolve it from within Itunes I did :  Edit, Preferences, Sharing.
    I took the tick out of "Share my library on my local network"
    Click OK.
    Closed iTunes/
    Reopened iTunes and I can drag and drop.
    I went back into Edit, Preferences, Sharing and put the tick back and clicked OK.
    Works fine now.

  • Why cannot I drag and drop songs from one playlist to another?

    Actually I have two questions.  I just updated from Leopard to snow leopard.  Now when I import songs, it says "Do you want to import to burn playlist?"  I click "yes".  Then when it is finished copying, I go to "playlists" on the top of the screen and click on the "burn playlist" and it says there are no items.  Where did the songs go.  I would like to burn a playlist that I imported this way.  I haven't tried arranging songs in the order I want them yet, but now see that is an issue also.  I also used to see a list of my playlists on the left side of the screen and the songs within each of those playlists when I clicked on them and easily could drag and drop songs from one playlist to another.  How do I do the same functions that I used to do before I updated? Does this update make it impossible to do the same functions as before?  Where can I find a "manual" of sorts to direct me to explain this new format?  If there is no way to do these things, I will have to say that I want my old iTunes back.  Can I do so???  Actually, the only reason I updated was so that I could play pix and movies from my camera into iPhoto.  When I did so, it said I had to update other programs to get iPhoto to work.  I am trying very hard not to be very frustrated.  PLEASE HELP!!!!!!!!!!!!!!!!!!

    After poking around for a while figured how to do things in this new iTunes.  Not as intuitive as the old one.  Sorry I don't have time to tell what I figured out.  Maybe some other time.

Maybe you are looking for