Package javax.swing

Examples of javax.swing.TransferHandler$DropHandler


    @Override
    public void dragEnter(DropTargetDragEvent e) {
        DataFlavor[] flavors = e.getCurrentDataFlavors();

        JComponent c = (JComponent)e.getDropTargetContext().getComponent();
        TransferHandler importer = c.getTransferHandler();

        if (importer != null && importer.canImport(c, flavors)) {
            canImport = true;
        } else {
            canImport = false;
        }
View Full Code Here


    @Override
    public void drop(DropTargetDropEvent e) {
        int dropAction = e.getDropAction();

        JComponent c = (JComponent)e.getDropTargetContext().getComponent();
        TransferHandler importer = c.getTransferHandler();

        if (canImport && importer != null && actionSupported(dropAction) && isDropable(e.getSource())) {
            e.acceptDrop(dropAction);

            try {
View Full Code Here

    setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    setLayoutOrientation(JList.VERTICAL);
    getSelectionModel().addListSelectionListener(this);
    setDragEnabled(true);

    setTransferHandler(new TransferHandler() {
      public int getSourceActions(JComponent c) {
        return COPY;
      }

      protected Transferable createTransferable(JComponent c) {
View Full Code Here

      MouseInputAdapter starter = new MouseInputAdapter()
      {
        @Override
          public void mousePressed(MouseEvent e)
          {
            TransferHandler handler = (TransferHandler)
              ReflectionUtils.invokeMethod("getTransferHandler", component,
              new Class[] {}, new Object[] {});
            handler.exportAsDrag(component, e, transferType);
           
          }
      };
     
      component.addMouseListener(starter);
View Full Code Here

    @Override
    public void exportToClipboard(JComponent pcomp, Clipboard pclip, int action) throws IllegalStateException {
        final Clipboard clip = pclip;
        final JComponent comp = pcomp;
        TransferHandler th = comp.getTransferHandler();
        if (th != null) {
            if (th.hashCode() == hashCode() && ant instanceof Transferable) {
                switch (action) {
                    case COPY:
                        clip.setContents((Transferable) ant, DnDHandler.this);
                        break;
                    default:
View Full Code Here

        return scrollPane.getViewport().getSize();
    }

    @Override
    public void copy() {
        TransferHandler handler = imageLabel.getTransferHandler();
        Clipboard systemClipboard = Toolkit.getDefaultToolkit().getSystemClipboard();

        handler.exportToClipboard(imageLabel, systemClipboard,
            TransferHandler.COPY);
    }
View Full Code Here

        // recognize a drag gesture
        MouseListener ml = new MouseAdapter() {
            public void mousePressed(MouseEvent e) {
                JComponent c = (JComponent)e.getSource();
                TransferHandler th = c.getTransferHandler();
                th.exportAsDrag(c, e, TransferHandler.COPY);
            }
        };
        addMouseListener(ml);
    }
View Full Code Here

            if (dx > 5 || dy > 5) {
                log.warn( "Start a drag" );
                //This is a drag, not a click.
                JComponent c = (JComponent)e.getSource();
                //Tell the transfer handler to initiate the drag.
                TransferHandler handler = c.getTransferHandler();
                handler.exportAsDrag(c, firstMouseEvent, action);
                firstMouseEvent = null;
            }
        }  
    }
View Full Code Here

        table.setDefaultRenderer(String.class, new StringRenderer());
        table.getTableHeader().setReorderingAllowed(false);

        // drag-and-drop initialization
        table.setDragEnabled(true);
        table.setTransferHandler(new TransferHandler() {


            @Override
            protected Transferable createTransferable(JComponent c) {
                int rowIndex = table.getSelectedRow();
View Full Code Here

    setMyTransferHandlers((String) propertyComboBox.getSelectedItem());

    MouseListener myDragListener = new MouseAdapter() {
      public void mousePressed(MouseEvent e) {
        JComponent c = (JComponent) e.getSource();
        TransferHandler handler = c.getTransferHandler();
        handler.exportAsDrag(c, e, TransferHandler.COPY);
      }
    };
    l.addMouseListener(myDragListener);

    propertyComboBox.addActionListener(new ActionListener() {
View Full Code Here

TOP

Related Classes of javax.swing.TransferHandler$DropHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.