Want to drag and image and drop it another panel
please suggest me with few lines of code how can i proceed for the image drag and drop
Please read book(s) and/or tutorial(s). This is a forum, not a code factory.
[http://catb.org/~esr/faqs/smart-questions.html]
db
Similar Messages
-
I want to drag and drop a file to a JText area with its file icon
I want to drag and drop a file to a JText area with its file icon , but the problem is I cant show the file icon.
Anyone knows this.
this is my code.
import java.awt.*;
import java.awt.image.BufferedImage;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.dnd.DnDConstants;
import java.awt.dnd.DropTarget;
import java.awt.dnd.DropTargetDragEvent;
import java.awt.dnd.DropTargetDropEvent;
import java.awt.dnd.DropTargetEvent;
import java.awt.dnd.DropTargetListener;
import java.io.File;
import javax.swing.*;
import javax.swing.filechooser.FileSystemView;
public class FileDrag extends JFrame implements DropTargetListener {
DropTarget dt;
File file;
JTextArea ta;
JLabel lbl;
Graphics g;
ImageIcon tmpIcon;
public FileDrag() {
super("Drop Test");
setSize(300, 300);
getContentPane().add(
new JLabel("Drop a list from your file chooser here:"),
BorderLayout.NORTH);
ta = new JTextArea();
ta.setBackground(Color.white);
getContentPane().add(ta);
dt = new DropTarget(ta, this);
setVisible(true);
public void dragEnter(DropTargetDragEvent dtde) {
System.out.println("Drag Enter");
public void dragExit(DropTargetEvent dte) {
System.out.println("Source: " + dte.getSource());
System.out.println("Drag Exit");
public void dragOver(DropTargetDragEvent dtde) {
System.out.println("Drag Over");
public void dropActionChanged(DropTargetDragEvent dtde) {
System.out.println("Drop Action Changed");
public void drop(DropTargetDropEvent dtde) {
FileSystemView view = FileSystemView.getFileSystemView();
JLabel testb;
Icon icon = null;
Toolkit tk;
Dimension dim;
BufferedImage buff = null;
try {
Transferable tr = dtde.getTransferable();
DataFlavor[] flavors = tr.getTransferDataFlavors();
for (int i = 0; i < flavors.length; i++) {
System.out.println("Possible flavor: " + flavors.getMimeType());
if (flavors.isFlavorJavaFileListType()) {
dtde.acceptDrop(DnDConstants.ACTION_COPY);
ta.setText("Successful file list drop.\n\n");
java.util.List list = (java.util.List) tr.getTransferData(flavors);
for (int j = 0; j < list.size(); j++) {
System.out.println(list.get(j));
file = (File) list.get(j);
icon = view.getSystemIcon(file);
ta.append(list.get(j) + "\n");
ta.append("\n");
tk = Toolkit.getDefaultToolkit();
dim = tk.getBestCursorSize(icon.getIconWidth(), icon.getIconHeight());
buff = new BufferedImage(dim.width, dim.height, BufferedImage.TYPE_INT_ARGB);
icon.paintIcon(ta, buff.getGraphics(), 10, 10);
repaint();
dtde.dropComplete(true);
return;
System.out.println("Drop failed: " + dtde);
dtde.rejectDrop();
} catch (Exception e) {
e.printStackTrace();
dtde.rejectDrop();
public static void main(String args[]) {
new FileDrag();
}This appears to be a long-standing bug:
https://bugzilla.mozilla.org/show_bug.cgi?id=634720
and the accepted workaround is stated in comment 11.
Oddly, it's possible to do the reverse, i.e. drag multiple eml files from Explorer to a TB folder. -
Can i make a book in iPhoto without using any of the built in layout templates, which are too limiting when i have already cropped my pictures to show just what I want. Ideally I just want to drag and drop and arrange and size the pictures myself
If you have Pages you can create customs pages for your book as TD suggested. If you have Pages from iWork 09 or 11 this app will add 80 or so additional frames to those offered: Frames and Strokes Installer. Don't use it on the latest Pages version, however.
This tutorial shows how to create a custom page with the theme's background: iP11 - Creating a Custom Page, with the Theme's Background for an iPhoto Book. Once the page is complete to get it into iPhoto as a jpeg file follow these steps:
Here's how to get any file into iPhoto as a jpeg file:
1 - open the file in any application that will open it.
2 - type Command+P to start the print process.
3 - click on the PDF button and select "Save PDF to iPhoto".
NOTE: If you don't have any of those options go to Toad's Cellar and download these two files:
Save PDF to iPhoto 200 DPI.workflow.zip
Save PDF to iPhoto 300 DPI.workflow.zip
Unzip the files and place in the HD/Library/PDF Services folder and reboot.
4 - select either of the files above (300 dip is used for photos to be included in a book that will be ordered).
5 - in the window that comes up enter an album name or select an existing album and hit the Continue button.
That will create a 200 or 300 dpi jpeg file of the item being printed and import it into iPhoto. For books to be printed choose 300 dpi. -
Does anybody know how to enable drag and drop onto a panel? I
need my users to be able to choose an image from a grid and place
it where ever they want on a panel or something. How can I do this
in flex? I know how to do drag and drop from grid to grids or
select boxes. I just can't get to place it on a panel.
Thanks for any insightThanks a million. This definitely helps out a lot. Do you
know of a way where you could put all of them on the panel and
control their layout? Basically, I need the user to be able to pick
as few or as many of the flags they want and place them on the
panel to make a collage. So the end user can drag the items around
and put them in the panel however they see fit.
Once again, thanks. -
Problem every time i want to drag and drop some columns
I was working in some columns , then in column properties i uncheck box : Wrap Text from TAB : Styles
then i save as system-wide default as data type ! i got this message error :
The current xml is invalid with the following errors: Bad xml instance! <?xml version="1.0"?> <sawsavedformat:metadata xmlns:sawsavedformat="com.siebel.analytics.web/savedformat/v1.1"><sawsavedformat:datatypeSavedFormats><sawsavedformat:datatypeFormat xmlns:saw="com.siebel.analytics.web/report/v1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" datatype="GDT:real"><saw:displayFormat><saw:formatSpec suppress="suppress" wrapText="true" visibility="visible" hAlign="right" vAlign="top" imagePlacement="right"><saw:dataFormat xsi:type="saw:number" commas="false" negativeType="minus" minDigits="0" maxDigits="0"/></saw:formatSpec></saw:displayFormat><saw:tableHeading><saw:displayFormat><saw:formatSpec/></saw:displayFormat></saw:tableHeading><saw:columnHeading><saw:displayFormat><saw:formatSpec/></saw:displayFormat></saw:columnHeading></sawsavedformat:datatypeFormat><sawsavedformat:datatypeFormat xmlns:saw="com.siebel.analytics.web/report/v1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" datatype="GDT:text"><saw:displayFormat><saw:formatSpec suppress="suppress" wrapText="false" visibility="visible" hAlign="left" vAlign="top" noWrap="true" imagePlacement="left" interaction="drill"/></saw:displayFormat><saw:tableHeading><saw:displayFormat><saw:formatSpec/></saw:displayFormat></saw:tableHeading><saw:columnHeading><saw:displayFormat><saw:formatSpec interaction="drill"/></saw:displayFormat></saw:columnHeading></sawsavedformat:datatypeFormat></sawsavedformat:datatypeSavedFormats></sawsavedformat:metadata> Line:2, Col:1116, Attribute 'noWrap' is not declared for element 'formatSpec'
This problem annoying me even i cannot drag and drop to build my Answer Report in some column :( ... teee heeee ... anyone can help me , also a pop up message show this :
The current xml is invalid with the following errors:
Bad xml instance!
<?xml version="1.0"?>
<sawmd:reportMetadata xmlns:saw="com.siebel.analytics.web/report/v1.1" xmlns:sawx="com.siebel.analytics.web/expression/v1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sawmd="oracle.bi.presentation/reportmetadata/v1" subjectArea=""MINISTRY_STD_ATT""><sawmd:columnInfo xsi:type="sawmd:regularColumnInfo" columnID="ceb07bca5c4142c11" baseFormula=""EDC_STUDENT_REGISTRATION"."NOTE"" resolvedFormula=""EDC_STUDENT_REGISTRATION"."NOTE"" writeEnabled="false" picklistEnabled="false" multivalueEnabled="false"><saw:columnFormula><sawx:expr xsi:type="sawx:sqlExpression">"EDC_STUDENT_REGISTRATION"."NOTE"</sawx:expr></saw:columnFormula><sawmd:SQLInfo dataType="varchar" nullable="true" aggType="nonAgg" aggRule="none" category="text" primaryType="text" displayFormula=""EDC_STUDENT_REGISTRATION"."NOTE"" sqlFormula=""MINISTRY_STD_ATT"."EDC_STUDENT_REGISTRATION"."NOTE"" hasSortKey="false"/><sawmd:columnDefaults><saw:tableHeading><saw:caption><saw:text>EDC_STUDENT_REGISTRATION</saw:text></saw:caption></saw:tableHeading><saw:columnHeading><saw:caption><saw:text>NOTE</saw:text></saw:caption></saw:columnHeading><saw:displayFormat><saw:formatSpec suppress="suppress" visibility="visible" hAlign="left" vAlign="top" noWrap="true" imagePlacement="left" interaction="drill"/></saw:displayFormat></sawmd:columnDefaults></sawmd:columnInfo></sawmd:reportMetadata>
Line:2, Col:1402, Attribute 'noWrap' is not declared for element 'formatSpec'Hi,
Did you find a solution to this. I am also seeing the same error in 11g 11.1.1.5
My Scenario:
I have drill-in place enabled for a report column and I drill-down on Product Category column to get the breakdown by Product Names. So far good. Then when I click on the 'Analyze' report link I get the below error.
Error Displaying Results
The current xml is invalid with the following errors: Bad xml instance!
This use case was working fine in 10G.
--Joe -
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.) -
Drag and Drop Between two Panels
Hi,
I am working with Swings,i created two Panels A and B. I kept some GIF or Image in Panel A,i would like to drag the gif object in to Panel B.
when i try like this,my mouse could not communicate with two panels A and B.mouse events working Individualey,i mean mouse events working in same panel.
Plz let me know how to communicate with two different panels with mouse. Drag and Drop between Panel A and Panel B.
Thanking you
MyProblemsYou might check out the Drag and Drop tutorial, especially the section Data Transfer with a Custom Component.
Here's another approach using an overlayed non–opaque JPanel as a transfer device. The image label is transfered to the (fake) glass pane and dragged. On mouse release it is added to the JPanel below. Although I didn't build in any boundry–checking it would be a useful thing. Mostly to ensure a suitable drop target and component location in it.
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.net.*;
import javax.imageio.ImageIO;
import javax.swing.*;
import javax.swing.event.*;
public class DraggingTest
public static void main(String[] args)
LeftPanel left = new LeftPanel();
JPanel right = new JPanel();
right.setBackground(new Color(200,240,220));
right.setLayout(null);
JPanel panel = new JPanel(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.weightx = 1.0;
gbc.weighty = 1.0;
gbc.fill = gbc.BOTH;
panel.add(left, gbc);
panel.add(right, gbc);
JPanel glassPanel = new JPanel();
glassPanel.setOpaque(false);
JPanel overlay = new JPanel();
OverlayLayout layout = new OverlayLayout(overlay);
overlay.setLayout(layout);
overlay.add(glassPanel);
overlay.add(panel);
ImageMover mover = new ImageMover(left, right, glassPanel);
glassPanel.addMouseListener(mover);
glassPanel.addMouseMotionListener(mover);
JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().add(overlay);
f.setSize(400,400);
f.setLocation(600,325);
f.setVisible(true);
class LeftPanel extends JPanel
Image image;
JLabel label;
public LeftPanel()
loadImage();
setBackground(Color.white);
setLayout(null);
label = new JLabel(new ImageIcon(image));
label.setName("imageLabel");
Dimension d = label.getPreferredSize();
label.setBounds(40, 40, d.width, d.height);
add(label);
private void loadImage()
String fileName = "images/dukeWaveRed.gif";
try
URL url = getClass().getResource(fileName);
image = ImageIO.read(url);
catch(MalformedURLException mue)
System.out.println(mue.getMessage());
catch(IOException ioe)
System.out.println(ioe.getMessage());
class ImageMover extends MouseInputAdapter
LeftPanel left;
JPanel right, glassPanel;
JPanel activePanel;
Component selectedComponent; // imageLabel
Point offset;
boolean dragging, selected;
public ImageMover(LeftPanel lp, JPanel p, JPanel gp)
left = lp;
right = p;
glassPanel = gp;
offset = new Point();
dragging = false;
selected = false;
public void mousePressed(MouseEvent e)
Point p = e.getPoint();
// which panel is the mouse over
if(!setActivePanel(p));
return;
// get reference to imageLabel or return
selectedComponent = getImageLabel();
if(selectedComponent == null)
return;
Rectangle labelR = selectedComponent.getBounds();
Rectangle panelR = activePanel.getBounds();
if(labelR.contains(p.x - panelR.x, p.y))
activePanel.remove(selectedComponent);
selected = true;
glassPanel.add(selectedComponent);
offset.x = p.x - labelR.x - panelR.x;
offset.y = p.y - labelR.y - panelR.y;
dragging = true;
public void mouseReleased(MouseEvent e)
Point p = e.getPoint();
if(!contains(glassPanel, selectedComponent))
return;
glassPanel.remove(selectedComponent);
setActivePanel(p);
activePanel.add(selectedComponent);
Rectangle r = activePanel.getBounds();
int x = p.x - offset.x - r.x;
int y = p.y - offset.y;
Dimension d = selectedComponent.getSize();
selectedComponent.setBounds(x, y, d.width, d.height);
glassPanel.repaint();
activePanel.repaint();
dragging = false;
public void mouseDragged(MouseEvent e)
if(dragging)
Point p = e.getPoint();
int x = p.x - offset.x;
int y = p.y - offset.y;
Dimension d = selectedComponent.getSize();
selectedComponent.setBounds(x, y, d.width, d.height);
if(!selected)
activePanel.repaint();
selected = false;
glassPanel.repaint();
private boolean contains(JPanel p, Component comp)
Component[] c = p.getComponents();
for(int j = 0; j < c.length; j++)
if(c[j] == comp)
return true;
return false;
private boolean setActivePanel(Point p)
activePanel = null;
Rectangle r = left.getBounds();
if(r.contains(p))
activePanel = left;
r = right.getBounds();
if(r.contains(p))
activePanel = right;
if(activePanel != null)
return true;
return false;
private Component getImageLabel()
Component[] c = activePanel.getComponents();
for(int j = 0; j < c.length; j++)
if(c[j].getName().equals("imageLabel"))
return c[j];
return null;
} -
Drag and Drop from Files panel
I am having trouble dragging JPG files from the Files panel
to insert in my pages. I have a number of pages created from the
same template and the ability to drag and drop an image from the
Files panel doesn't work for all pages.
Some pages let me drag the file across, other times I have to
use the Insert command and browse to select the file. Is there an
option that I've somehow turned off for these pages?
Thanks.> Is there an option that I've somehow turned off for
these pages?
I don't think so. What happens on those pages that fail? Do
you get an
error? Do you just get nothing? Do you get the circle/slash
cursor? Are
you dropping onto non-editable turf?
Personally, I have never found the INSERT menu option to be
too much
trouble....
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go
- DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs,
Tutorials & Resources
==================
"Bagheera62" <[email protected]> wrote in
message
news:gngsur$9ri$[email protected]..
>I am having trouble dragging JPG files from the Files
panel to insert in my
> pages. I have a number of pages created from the same
template and the
> ability
> to drag and drop an image from the Files panel doesn't
work for all pages.
>
> Some pages let me drag the file across, other times I
have to use the
> Insert
> command and browse to select the file. Is there an
option that I've
> somehow
> turned off for these pages?
>
> Thanks.
> -
Drag and Drop image is Duplicated
Hi,
In my code, I want to drag and drop an image from a list populated from a folder, and its information is populated from an xml file. Now, I can drag the image from the list and drop it in the container, However, when now, I want to drag around the dropped image, it is duplicated, an extra image is created in the canvas. So, if anyone can tell me how not to create an extra copy of the image in the new container (canvas) that it was dragged to.
Here is the code:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical"
name="Drag and Drop Tutorial"
creationComplete="init()"
initialize="pictureService.send()">
<mx:Script>
<![CDATA[
import mx.controls.Image;
import mx.core.DragSource;
import mx.core.IUIComponent;
import mx.managers.DragManager;
import mx.events.DragEvent;
import mx.controls.Alert;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.collections.ArrayCollection;
[Bindable] private var pictureData:ArrayCollection;
private function resultHandler(event:ResultEvent):void{
pictureData = event.result.data.image;
private function faultHandler(event:FaultEvent):void{
//code
public function init():void
// a mouseDown event will start the drag
list.dataProvider = pictureData;
//picture in the list is being dragged
this.picture.addEventListener( MouseEvent.MOUSE_DOWN, beginDrag );
// accepting a drag/drop operation...
this.area.addEventListener( DragEvent.DRAG_ENTER, acceptDrop );
// handling the drop...
this.area.addEventListener( DragEvent.DRAG_DROP, handleDrop );
public function beginDrag( mouseEvent:MouseEvent ):void
// the drag initiator is the object being dragged (target of the mouse event)
var dragInitiator:IUIComponent = mouseEvent.currentTarget as IUIComponent;
// the drag source contains data about what's being dragged
var dragSource:DragSource = new DragSource();
// Add the data to the object.
dragSource.addData(1, 'value');
// Create a copy of the coin image to use as a drag proxy.
var dragProxy:Image = new Image();
dragProxy.source = mouseEvent.currentTarget.source;
dragProxy.setActualSize(mouseEvent.currentTarget.width,mouseEvent.currentTarget.height)
// ask the DragManger to begin the drag
DragManager.doDrag( dragInitiator, dragSource, mouseEvent, dragProxy );
public function acceptDrop( dragEvent:DragEvent ):void
var dropTarget:IUIComponent = dragEvent.currentTarget as IUIComponent;
// accept the drop
DragManager.acceptDragDrop( dropTarget );
// show feedback
DragManager.showFeedback( DragManager.COPY );
public function handleDrop( dragEvent:DragEvent ):void
var dragInitiator:IUIComponent = dragEvent.dragInitiator;
var dropTarget:IUIComponent = dragEvent.currentTarget as IUIComponent;
if(dragEvent.dragSource.hasFormat("items"))
var items:Array = dragEvent.dragSource.dataForFormat("items") as Array;
var img:Image = new Image();
img.x=dragEvent.localX;
img.y=dragEvent.localY;
img.width = 50;
img.height=50;
img.source="assets/" + items[0].id + ".jpg";
img.addEventListener(MouseEvent.MOUSE_MOVE,beginDrag);
area.addChild(img);
else
dragEvent.dragInitiator.x=dragEvent.localX
dragEvent.dragInitiator.y=dragEvent.localY
]]>
</mx:Script>
<mx:HTTPService id="pictureService"
url="data/data.xml"
result="resultHandler(event)"
fault="faultHandler(event)"/>
<mx:DataGrid id="list" width="238" height="200" y="26" x="10" labelField="src" dragEnabled="true"
dataProvider="{pictureData}">
<mx:columns>
<mx:DataGridColumn dataField="id" id="code">
</mx:DataGridColumn>
<mx:DataGridColumn id="picture" draggable="true" >
<mx:itemRenderer>
<mx:Component>
<mx:Image source="assets/{data.id}.jpg" />
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
</mx:columns>
</mx:DataGrid>
<mx:Canvas id="area" x="266" y="28" width="436" height="401" backgroundColor="#c0c0c0"
dragDrop="handleDrop(event)" >
</mx:Canvas>
</mx:Application>your handleDrop is called twice. you have assigned this eventlistener twice - one in init function and one in inline.
remove one and it works. -
How to drag and drop href image from webbrowser to office using vsto c# wpf?
I want to drag and drop href images from web browser to office using C# wpf. Is it possible to drag href images ? give me the solution
Hi,
Are you developing an Office Add-in application? Do you mean you hold a wpf Web Browser control in the Office Add-in project?
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
Drag and drop an image over a JPanel (only change position on same JPanel)
Hi all,
there is JPanel added to a JDialog.
There is a BufferedImage on the JPanel: I need to let the image be dragged and dropped in another position over the same JPanel and read the new position's coordinates.
(Maybe the image has to be wrapped in a JComponent?)
Thanks in advance for any suggestions.
Ludovico(Maybe the image has to be wrapped in a JComponent?)Just add the image to a JLabel and add the label to the panel.
-
How to drag and drop a file with its Systemfile icon to a Jtext area
I want to drag and drop a file to a JText area with its system file icon , but the problem is I cant show the file icon.
Anyone knows this.
this is my code.
import java.awt.*;
import java.awt.image.BufferedImage;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.dnd.DnDConstants;
import java.awt.dnd.DropTarget;
import java.awt.dnd.DropTargetDragEvent;
import java.awt.dnd.DropTargetDropEvent;
import java.awt.dnd.DropTargetEvent;
import java.awt.dnd.DropTargetListener;
import java.io.File;
import javax.swing.*;
import javax.swing.filechooser.FileSystemView;
public class FileDrag extends JFrame implements DropTargetListener {
DropTarget dt;
File file;
JTextArea ta;
JLabel lbl;
Graphics g;
ImageIcon tmpIcon;
public FileDrag() {
super("Drop Test");
setSize(300, 300);
getContentPane().add(
new JLabel("Drop a list from your file chooser here:"),
BorderLayout.NORTH);
ta = new JTextArea();
ta.setBackground(Color.white);
getContentPane().add(ta);
dt = new DropTarget(ta, this);
setVisible(true);
public void dragEnter(DropTargetDragEvent dtde) {
System.out.println("Drag Enter");
public void dragExit(DropTargetEvent dte) {
System.out.println("Source: " + dte.getSource());
System.out.println("Drag Exit");
public void dragOver(DropTargetDragEvent dtde) {
System.out.println("Drag Over");
public void dropActionChanged(DropTargetDragEvent dtde) {
System.out.println("Drop Action Changed");
public void drop(DropTargetDropEvent dtde) {
FileSystemView view = FileSystemView.getFileSystemView();
JLabel testb;
Icon icon = null;
Toolkit tk;
Dimension dim;
BufferedImage buff = null;
try {
Transferable tr = dtde.getTransferable();
DataFlavor[] flavors = tr.getTransferDataFlavors();
for (int i = 0; i < flavors.length; i++) {
System.out.println("Possible flavor: " + flavors.getMimeType());
if (flavors[i].isFlavorJavaFileListType()) {
dtde.acceptDrop(DnDConstants.ACTION_COPY);
ta.setText("Successful file list drop.\n\n");
java.util.List list = (java.util.List) tr.getTransferData(flavors[i]);
for (int j = 0; j < list.size(); j++) {
System.out.println(list.get(j));
file = (File) list.get(j);
icon = view.getSystemIcon(file);
ta.append(list.get(j) + "\n");
ta.append("\n");
tk = Toolkit.getDefaultToolkit();
dim = tk.getBestCursorSize(icon.getIconWidth(), icon.getIconHeight());
buff = new BufferedImage(dim.width, dim.height, BufferedImage.TYPE_INT_ARGB);
icon.paintIcon(ta, buff.getGraphics(), 10, 10);
repaint();
dtde.dropComplete(true);
return;
System.out.println("Drop failed: " + dtde);
dtde.rejectDrop();
} catch (Exception e) {
e.printStackTrace();
dtde.rejectDrop();
public static void main(String args[]) {
new FileDrag();I want to drag and drop a file to a JText area with its system file icon , but the problem is I cant show the file icon.
Anyone knows this.
this is my code.
import java.awt.*;
import java.awt.image.BufferedImage;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.dnd.DnDConstants;
import java.awt.dnd.DropTarget;
import java.awt.dnd.DropTargetDragEvent;
import java.awt.dnd.DropTargetDropEvent;
import java.awt.dnd.DropTargetEvent;
import java.awt.dnd.DropTargetListener;
import java.io.File;
import javax.swing.*;
import javax.swing.filechooser.FileSystemView;
public class FileDrag extends JFrame implements DropTargetListener {
DropTarget dt;
File file;
JTextArea ta;
JLabel lbl;
Graphics g;
ImageIcon tmpIcon;
public FileDrag() {
super("Drop Test");
setSize(300, 300);
getContentPane().add(
new JLabel("Drop a list from your file chooser here:"),
BorderLayout.NORTH);
ta = new JTextArea();
ta.setBackground(Color.white);
getContentPane().add(ta);
dt = new DropTarget(ta, this);
setVisible(true);
public void dragEnter(DropTargetDragEvent dtde) {
System.out.println("Drag Enter");
public void dragExit(DropTargetEvent dte) {
System.out.println("Source: " + dte.getSource());
System.out.println("Drag Exit");
public void dragOver(DropTargetDragEvent dtde) {
System.out.println("Drag Over");
public void dropActionChanged(DropTargetDragEvent dtde) {
System.out.println("Drop Action Changed");
public void drop(DropTargetDropEvent dtde) {
FileSystemView view = FileSystemView.getFileSystemView();
JLabel testb;
Icon icon = null;
Toolkit tk;
Dimension dim;
BufferedImage buff = null;
try {
Transferable tr = dtde.getTransferable();
DataFlavor[] flavors = tr.getTransferDataFlavors();
for (int i = 0; i < flavors.length; i++) {
System.out.println("Possible flavor: " + flavors.getMimeType());
if (flavors[i].isFlavorJavaFileListType()) {
dtde.acceptDrop(DnDConstants.ACTION_COPY);
ta.setText("Successful file list drop.\n\n");
java.util.List list = (java.util.List) tr.getTransferData(flavors[i]);
for (int j = 0; j < list.size(); j++) {
System.out.println(list.get(j));
file = (File) list.get(j);
icon = view.getSystemIcon(file);
ta.append(list.get(j) + "\n");
ta.append("\n");
tk = Toolkit.getDefaultToolkit();
dim = tk.getBestCursorSize(icon.getIconWidth(), icon.getIconHeight());
buff = new BufferedImage(dim.width, dim.height, BufferedImage.TYPE_INT_ARGB);
icon.paintIcon(ta, buff.getGraphics(), 10, 10);
repaint();
dtde.dropComplete(true);
return;
System.out.println("Drop failed: " + dtde);
dtde.rejectDrop();
} catch (Exception e) {
e.printStackTrace();
dtde.rejectDrop();
public static void main(String args[]) {
new FileDrag(); -
I can't drag and drop from a data CD I recorded
I recently burned some audiobooks files (in mp3 format) as data cd's in Toast 8.0.1. When I go to reload them back onto my 20" 2 Ghz Dual Core Intel I can't drag and drop the files directly into any folder while using the columns view in a finder window. I can do it if I drag onto the music folder and let it spring open down to the level of the folder. I also can drag the mp3's into iTunes and then into the folder. This is not CD related since I used several diff brands.
I constantly update, backup, repair permissions, and do other maintenance so everything is up to date. I have noticed this behavior just since I started to use the program called Audiobook Builder. I am (and have always used) a non-admin user account. When this started a few months ago it seemed to go away with a restart, permission repair, or a logout but now it seems permanant. I checked user permissions on my home folder - I have not added any software since adding Audiobook Builder. Any idea's? I read something about trashing a com.apple pref but didn't try that.
I suspect Audiobook Builder since it changes the permissions and filetype to the iTunes Audiobook filetype but have not seen anyone reference this.
wesdj_paige wrote:
While the programming of course could be done, the idea of a function that performs on original unprocessed images seems to violate the whole idea of what Lightroom was designed to be. At least that's my opinion. Of course, the idea that Adobe should do this programming for a relatively small number of people (you're one of a very few people to ask for this, that I have read) seems to be something that isn't going to happen.
I agree, I can't see much reason for drag-and-drop to drag the unprocessed image - in other words, an image that isn't the one that you see when you drag and drop. I can see that just filling this forum with "why the heck does it do that????????" posts. I could be wrong, but I suspect that Adobe won't do that.
But if you do want to drag-and-drop the original unprocessed image, you can do it very easily now. Right click the image, choose "show in Explorer", and then drag-and-drop from Explorer. -
Using Blackberry Link on for Mac - I want to drag and drop a video file from Q10 to Mac Desktop. Does not work. When I "right click" mouse over a video file, it gives option to "copy to desktop." This feature does not work.
Thanx. I tried with the different overloaded startDrag() which allows an image to be set.
As my requirement is such that I do not want any image to be shown aruond next to cursor, so I set Image field to null.
On windows it does not show any block (Image) but on Mac it does :(. -
Hi,
I want to drag and drop an item onto an item of the TileList
control. for example, i have a list of Category image in a TileList
and few items in another TileList, now i need to drag the items and
drop them onto a Category in the Category TileList. how can i do
this...?
Please help me..
Thanks in AdvanceGot the answer from Joan Lafferty on the FlexCoders forum:
Use calculateDropIndex(event:DragEvent) that is a function
for a TileList. In will return the index where the item was
dropped.
And that works:
private function myDragDrop(e:DragEvent):void {
var dropIndex:int = tilelist1.calculateDropIndex(e);
Alert.show("dropIndex: " + dropIndex);
Thanks Joan!
Maybe you are looking for
-
md5 reborned hasher which has worked previously no longer works after update to FF version 20 . the redesigned download box doesn't give the option to use the hasher.
-
Trouble downloading anything on MacBook. "Cannot create a file"
Whenever I try to download anything off of the interent, my computer says that it cannot create a file.
-
More about pop ups - epic fail
So, yeah, I'm working on this portfolio site, and I'm trying to nest these pop ups inside a scrollpane ... the debugger isn't finding anything wrong with the code, but it's not working at all. Even my rollovers are acting weird. I'm no expert, but I'
-
I know you can't download a file from an applet directly 'cause of the security contraints, what I'm asking is if anyone knows another simple way to take text written in the applet by the user and place it into a file and allow the user to download i
-
Time machine-- can't eject backup drive
Hi, everyone. I have a backup drive attached to time machine. I need to use the firewire port my external drive is plugged into (there is only one) to upload from my video camera. But I it won't let me eject the drive, even though I have gone into Ti