How can I use Drag-and-Drop in Swing to get file path?

In case you don’t want to spend too much time researching this relatively complex subject, and you’re on Java 7 or later, here’s a quick example of how to accept dropped files with a JTextArea as a drop target: JTextArea myPanel = new JTextArea(); myPanel.setDropTarget(new DropTarget() { public synchronized void drop(DropTargetDropEvent evt) { try { … Read more

How do I detect a file is being dragged rather than a draggable element on my page?

You can detect what is being dragged by inspecting dataTransfer.types. This behaviour is not (yet) consistent across browsers so you have to check for the existence of ‘Files’ (Chrome) and ‘application/x-moz-file’ (Firefox). // Show the dropzone when dragging files (not folders or page // elements). The dropzone is hidden after a timer to prevent // … Read more

How to make resizeable?

The best method would be to use CSS3. It supported by at least Webkit and Gecko. According to the w3c spec: div.my_class { resize:both; overflow:auto; /* something other than visible */ } Webkit and Firefox do not interpret the specs the same way. In Webkit the size is limited to the width and height set. … Read more

jQuery.on(“drop”) not firing

You need to cancel all events $(“html”).on(“dragover”, function(event) { event.preventDefault(); event.stopPropagation(); $(this).addClass(‘dragging’); }); $(“html”).on(“dragleave”, function(event) { event.preventDefault(); event.stopPropagation(); $(this).removeClass(‘dragging’); }); $(“html”).on(“drop”, function(event) { event.preventDefault(); event.stopPropagation(); alert(“Dropped!”); });

Drag and drop items in RecyclerView with GridLayoutManager

There is actually a better way to achieve this. You can use some of the RecyclerView‘s “companion” classes: ItemTouchHelper, which is a utility class to add swipe to dismiss and drag & drop support to RecyclerView. and its ItemTouchHelper.Callback, which is the contract between ItemTouchHelper and your application // Create an `ItemTouchHelper` and attach it … Read more

Pass object through dataTransfer

You should pass the object to JSON.stringify before using setData because you can only store strings. var j = JSON.stringify(foo); e.originalEvent.dataTransfer.setData(“foo”, j); And the other way round you have to reconvert the string to an object: var obj = JSON.parse(e.originalEvent.dataTransfer.getData(“foo”)); console.log(“foo is:”, obj); See this working Fiddle

How to automate drag & drop functionality using Selenium WebDriver Java

There is a page documenting Advanced User Interactions; which has a lot of great examples on how to generate a sequence of actions, you can find it here // Configure the action Actions builder = new Actions(driver); builder.keyDown(Keys.CONTROL) .click(someElement) .click(someOtherElement) .keyUp(Keys.CONTROL); // Then get the action: Action selectMultiple = builder.build(); // And execute it: selectMultiple.perform(); … Read more

When I make a draggable clone and drop it in a droppable I cannot drag it again

One way to do it is: $(document).ready(function() { $(“#container”).droppable({ accept: ‘.product’, drop: function(event, ui) { $(this).append($(“ui.draggable”).clone()); $(“#container .product”).addClass(“item”); $(“.item”).removeClass(“ui-draggable product”); $(“.item”).draggable({ containment: ‘parent’, grid: [150,150] }); } }); $(“.product”).draggable({ helper: ‘clone’ }); }); But I’m not sure if it is nice and clean coding.

HTML5 DnD dataTransfer setData or getData not working in every browser except Firefox

Ok, so after a bit more digging around, I found that the problem actually isn’t with Chrome, Safari, and Opera. What gave it away was that Firefox was supporting it and I just couldn’t say the other browsers are failing, since that’s something I’d normally accept for IE. The real cause of the issue is … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)