01: /*
02: * Copyright 2006-2007 Pentaho Corporation. All rights reserved.
03: * This software was developed by Pentaho Corporation and is provided under the terms
04: * of the Mozilla Public License, Version 1.1, or any later version. You may not use
05: * this file except in compliance with the license. If you need a copy of the license,
06: * please go to http://www.mozilla.org/MPL/MPL-1.1.txt.
07: *
08: * Software distributed under the Mozilla Public License is distributed on an "AS IS"
09: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to
10: * the license for the specific language governing your rights and limitations.
11: *
12: * Additional Contributor(s): Martin Schmid gridvision engineering GmbH
13: */
14: package org.pentaho.reportdesigner.crm.report.tests;
15:
16: import org.jetbrains.annotations.NotNull;
17:
18: import javax.swing.*;
19: import java.awt.*;
20: import java.awt.datatransfer.DataFlavor;
21: import java.awt.datatransfer.UnsupportedFlavorException;
22: import java.awt.dnd.DnDConstants;
23: import java.awt.dnd.DropTarget;
24: import java.awt.dnd.DropTargetDragEvent;
25: import java.awt.dnd.DropTargetDropEvent;
26: import java.awt.dnd.DropTargetEvent;
27: import java.awt.dnd.DropTargetListener;
28: import java.io.IOException;
29:
30: /**
31: * User: Martin
32: * Date: 13.02.2006
33: * Time: 18:05:40
34: */
35: @SuppressWarnings({"ALL"})
36: public class DropTest {
37: public static void main(@NotNull
38: String[] args) {
39: JFrame frame = new JFrame("DropTest");//NON-NLS
40: JLabel label = new JLabel("blub");//NON-NLS
41: frame.getContentPane().add(label, BorderLayout.CENTER);
42:
43: frame.pack();
44: frame.setVisible(true);
45:
46: //noinspection UNUSED_SYMBOL
47: DropTarget dropTarget = new DropTarget(label,
48: new DropTargetListener() {
49: public void dragEnter(@NotNull
50: DropTargetDragEvent dtde) {
51: }
52:
53: public void dragOver(@NotNull
54: DropTargetDragEvent dtde) {
55: }
56:
57: public void dropActionChanged(@NotNull
58: DropTargetDragEvent dtde) {
59: }
60:
61: public void dragExit(@NotNull
62: DropTargetEvent dte) {
63: }
64:
65: public void drop(@NotNull
66: DropTargetDropEvent dtde) {
67: dtde.acceptDrop(DnDConstants.ACTION_COPY);
68: try {
69: if (dtde
70: .getTransferable()
71: .isDataFlavorSupported(
72: DataFlavor.javaFileListFlavor)) {
73: java.util.List transferData = (java.util.List) dtde
74: .getTransferable()
75: .getTransferData(
76: DataFlavor.javaFileListFlavor);
77: for (Object o : transferData) {
78: System.out.println("o = " + o);//NON-NLS
79: }
80: }
81: } catch (UnsupportedFlavorException e) {
82: e.printStackTrace();
83: } catch (IOException e) {
84: e.printStackTrace();
85: }
86: }
87: });
88: }
89: }
|