List of usage examples for java.awt.dnd DragSource getDefaultDragSource
public static DragSource getDefaultDragSource()
From source file:JLabelDragSource.java
public JLabelDragSource(JLabel label) { this.label = label; // Use the default DragSource DragSource dragSource = DragSource.getDefaultDragSource(); // Create a DragGestureRecognizer and // register as the listener dragSource.createDefaultDragGestureRecognizer(label, DnDConstants.ACTION_COPY_OR_MOVE, this); }
From source file:FileTreeDragSource.java
public FileTreeDragSource(FileTree tree) { this.tree = tree; // Use the default DragSource DragSource dragSource = DragSource.getDefaultDragSource(); // Create a DragGestureRecognizer and // register as the listener dragSource.createDefaultDragGestureRecognizer(tree, DnDConstants.ACTION_COPY_OR_MOVE, this); }
From source file:TreeTester.java
public DndTree() { DragSource dragSource = DragSource.getDefaultDragSource(); dragSource.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_COPY_OR_MOVE, new TreeDragGestureListener()); DropTarget dropTarget = new DropTarget(this, new TreeDropTargetListener()); }
From source file:ColorSource.java
/** Create a new ColorSource object that displays the speciifed color */ public ColorSource(Color color) { // Save the color. Encapsulate it in a Transferable object so that // it can be used with cut-and-paste and drag-and-drop this.color = color; this.tcolor = new TransferableColor(color); // Set our default border this.setBorder(defaultBorder); // Listen for mouse clicks, and copy the color to the clipboard. this.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { copy();// w ww. ja v a 2 s . c o m } }); // Set up a DragGestureRecognizer that will detect when the user // begins a drag. When it detects one, it will notify us by calling // the dragGestureRecognized() method of the DragGestureListener // interface we implement below this.dragSource = DragSource.getDefaultDragSource(); dragSource.createDefaultDragGestureRecognizer(this, // Look for drags on us DnDConstants.ACTION_COPY_OR_MOVE, // Recognize these types this); // Tell us when recognized }
From source file:TreeTester.java
public DndTree(TreeModel model) { super(model); DragSource dragSource = DragSource.getDefaultDragSource(); dragSource.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_COPY_OR_MOVE, new TreeDragGestureListener()); DropTarget dropTarget = new DropTarget(this, new TreeDropTargetListener()); }
From source file:de.tor.tribes.ui.algo.AttackTimePanel.java
/** * Creates new form TestPanel/*from ww w . j av a2 s . co m*/ * * @param pListener */ public AttackTimePanel(SettingsChangedListener pListener) { initComponents(); mListener = pListener; dragSource = DragSource.getDefaultDragSource(); dragSource.createDefaultDragGestureRecognizer(jLabel5, DnDConstants.ACTION_COPY_OR_MOVE, AttackTimePanel.this); dragSource.createDefaultDragGestureRecognizer(jLabel6, DnDConstants.ACTION_COPY_OR_MOVE, AttackTimePanel.this); DropTarget dropTarget = new DropTarget(this, this); jTimeFrameList.setDropTarget(dropTarget); jSendTimeFrame.addColorisationListener(new ColorisationListener() { @Override public void newColors(ColorisationEvent ColorisationEvent_Arg) { updatePreview(); } }); dateTimeField.setActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { updatePreview(); } }); jTimeFrameList.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_DELETE) { deleteSelectedTimeSpan(); } } }); jArriveInPastLabel.setVisible(false); maxArriveTimeField.setActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { TimeFrame currentFrame = getTimeFrame(); if (currentFrame != null) { jArriveInPastLabel .setVisible(currentFrame.getArriveRange().getMaximum() < System.currentTimeMillis()); } } }); reset(); updatePreview(); }
From source file:de.tor.tribes.ui.windows.AbstractDSWorkbenchFrame.java
public AbstractDSWorkbenchFrame() { mFrameListeners = new LinkedList<>(); // getContentPane().setBackground(Constants.DS_BACK); dragSource = DragSource.getDefaultDragSource(); dragSource.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_COPY_OR_MOVE, this); DropTarget dropTarget = new DropTarget(this, this); this.setDropTarget(dropTarget); }
From source file:TransferableScribblePane.java
public TransferableScribblePane() { setPreferredSize(new Dimension(450, 200)); // We need a default size setBorder(normalBorder); // and a border. lines = new ArrayList(); // Start with an empty list of lines // Register interest in mouse button and mouse motion events. enableEvents(AWTEvent.MOUSE_EVENT_MASK | AWTEvent.MOUSE_MOTION_EVENT_MASK); // Enable drag-and-drop by specifying a listener that will be // notified when a drag begins. dragGestureListener is defined later. DragSource dragSource = DragSource.getDefaultDragSource(); dragSource.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_COPY_OR_MOVE, dragGestureListener); // Enable drops on this component by registering a listener to // be notified when something is dragged or dropped over us. this.setDropTarget(new DropTarget(this, dropTargetListener)); // Check whether the system allows us to drag an image of the line canDragImage = dragSource.isDragImageSupported(); }
From source file:ScribbleDragAndDrop.java
/** The constructor: set up drag-and-drop stuff */ public ScribbleDragAndDrop() { // Give ourselves a nice default border. // We'll change this border during drag-and-drop. setBorder(normalBorder);/*from w ww. j av a 2 s.c o m*/ // Register listeners to handle drawing addMouseListener(this); addMouseMotionListener(this); // Create a DragSource and DragGestureRecognizer to listen for drags // The DragGestureRecognizer will notify the DragGestureListener // when the user tries to drag an object dragSource = DragSource.getDefaultDragSource(); dragSource.createDefaultDragGestureRecognizer(this, // What component DnDConstants.ACTION_COPY_OR_MOVE, // What drag types? this);// the listener // Create and set up a DropTarget that will listen for drags and // drops over this component, and will notify the DropTargetListener DropTarget dropTarget = new DropTarget(this, // component to monitor this); // listener to notify this.setDropTarget(dropTarget); // Tell the component about it. }
From source file:com.eviware.soapui.SoapUI.java
private void buildUI() { // display used java version log.info("Used java version: " + System.getProperty("java.version")); frame.addWindowListener(new MainFrameWindowListener()); UISupport.setMainFrame(frame);// w w w . j a va2 s. c om navigator = new Navigator(workspace); navigator.addNavigatorListener(new InternalNavigatorListener()); desktopPanelsList = new JDesktopPanelsList(desktop); mainInspector = JInspectorPanelFactory.build(buildContentPanel(), SwingConstants.LEFT); mainInspector.addInspector( new JComponentInspector<JComponent>(buildMainPanel(), "Navigator", "The soapUI Navigator", true)); mainInspector.setCurrentInspector("Navigator"); frame.setJMenuBar(buildMainMenu()); frame.getContentPane().add(buildToolbar(), BorderLayout.NORTH); frame.getContentPane().add(mainInspector.getComponent(), BorderLayout.CENTER); frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); frame.setSize(1000, 750); mainInspector.setDividerLocation(250); mainInspector.setResizeWeight(0.1); navigator.selectModelItem(workspace); desktop.addDesktopListener(internalDesktopListener); ToolTipManager.sharedInstance().setInitialDelay(200); JTree mainTree = navigator.getMainTree(); DragSource dragSource = DragSource.getDefaultDragSource(); SoapUIDragAndDropHandler navigatorDragAndDropHandler = new SoapUIDragAndDropHandler( new NavigatorDragAndDropable(mainTree), DropType.ON + DropType.AFTER); dragSource.createDefaultDragGestureRecognizer(mainTree, DnDConstants.ACTION_COPY_OR_MOVE, navigatorDragAndDropHandler); desktop.init(); }