How can I set the priority mouse listener

The above code has many errors… Dont use null/Absolute LayoutManager. Have a look at Laying Out Components Within a Container. Dont call setSize on components and JFrame (if correct Layout Manager is implemented you can simply add components and call pack() on JFrame. Create and manipulate Swing components on EDT. Read more on Concurrency in … Read more

Java: mouseDragged and moving around in a graphical interface

Based on this example, the following program allows the user to drag the axes’ intersection to an arbitrary point, origin, which starts at the center of the panel. import java.awt.Cursor; import java.awt.Dimension; import java.awt.EventQueue; import java.awt.Graphics; import java.awt.Point; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.MouseMotionAdapter; import javax.swing.JFrame; import javax.swing.JPanel; /** * @see https://stackoverflow.com/a/15576413/230513 * @see https://stackoverflow.com/a/5312702/230513 … Read more

Drop image into contenteditable in Chrome to the cursor

If you can get the co-ordinates of the drop location (which I assume must be possible), you can do it as follows (untested). I’m assuming you’ve got the co-ordinates of the drop location relative to the viewport as variables x and y and the dropped image as the variable img: Demo: http://jsfiddle.net/KZqNj/ Code: var range; … Read more

How does one implement drag and drop for Android marker?

Implement Google Maps Android API v2, refer this: https://developers.google.com/maps/documentation/android/ and set on GoogleMap object setOnMarkerDragListener. For Ex: map.setOnMarkerDragListener(new OnMarkerDragListener() { @Override public void onMarkerDragStart(Marker arg0) { // TODO Auto-generated method stub Log.d(“System out”, “onMarkerDragStart…”+arg0.getPosition().latitude+”…”+arg0.getPosition().longitude); } @SuppressWarnings(“unchecked”) @Override public void onMarkerDragEnd(Marker arg0) { // TODO Auto-generated method stub Log.d(“System out”, “onMarkerDragEnd…”+arg0.getPosition().latitude+”…”+arg0.getPosition().longitude); map.animateCamera(CameraUpdateFactory.newLatLng(arg0.getPosition())); } @Override public void … 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

Drop event not firing in chrome

In order to have the drop event occur on a div element, you must cancel the ondragenter and ondragover events. Using jquery and your code provided… $(‘.drop’).on(‘drop dragdrop’,function(){ alert(‘dropped’); }); $(‘.drop’).on(‘dragenter’,function(event){ event.preventDefault(); $(this).html(‘drop now’).css(‘background’,’blue’); }) $(‘.drop’).on(‘dragleave’,function(){ $(this).html(‘drop here’).css(‘background’,’red’); }) $(‘.drop’).on(‘dragover’,function(event){ event.preventDefault(); }) For more information, check out the MDN page.

tkinter – How to drag and drop widgets?

The behavior you’re observing is caused by the fact that the event’s coordinates are relative to the dragged widget. Updating the widget’s position (in absolute coordinates) with relative coordinates obviously results in chaos. To fix this, I’ve used the .winfo_x() and .winfo_y() functions (which allow to turn the relative coordinates into absolute ones), and the … Read more

Internet Explorer 9 Drag and Drop (DnD)

I’ve found a workarround to make the native dnd api also work in IE with elements other than links and images. Add a onmousemove handler to the draggable container and call the native IE function element.dragDrop(), when the button is pressed: function handleDragMouseMove(e) { var target = e.target; if (window.event.button === 1) { target.dragDrop(); } … Read more

tech