当前位置: 首页>>代码示例>>Java>>正文


Java DropTarget类代码示例

本文整理汇总了Java中java.awt.dnd.DropTarget的典型用法代码示例。如果您正苦于以下问题:Java DropTarget类的具体用法?Java DropTarget怎么用?Java DropTarget使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DropTarget类属于java.awt.dnd包,在下文中一共展示了DropTarget类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createCenterPane

import java.awt.dnd.DropTarget; //导入依赖的package包/类
@Override
protected JComponent createCenterPane() {
	graphpanel = new SampleGraphPanel();
	graphpanel.setPreferredSize(new Dimension(600, 300));
	new DropTarget(graphpanel, new FileDropTargetListener() {
		@Override
		protected void openFile(File file) {
			// insert your own function for loading a file
			JOptionPane.showMessageDialog(graphpanel,
					"Opened " + file.getName());
		}

		@Override
		protected boolean canOpenFile() {
			// is GUI ready for opening a file?
			return true;
		}
	});
	return graphpanel;
}
 
开发者ID:KeepTheBeats,项目名称:alevin-svn2,代码行数:21,代码来源:PaneledGuiDemo.java

示例2: setDocument

import java.awt.dnd.DropTarget; //导入依赖的package包/类
@Override
public void setDocument(Document doc) {
    super.setDocument(doc);
    
    // Setting DelegatingTransferHandler, where CallbackTransferable will
    // be handled in importData method. 
    // For more details, please refer issue #53439        
    if (doc != null){
        TransferHandler thn = getTransferHandler();
        if( !(thn instanceof DelegatingTransferHandler) ) {
            DelegatingTransferHandler dth = new DelegatingTransferHandler(thn);
            setTransferHandler(dth);
        }

        DropTarget currDt = getDropTarget();
        if( !(currDt instanceof DelegatingDropTarget ) ) {
            DropTarget dt = new DelegatingDropTarget( currDt );
            setDropTarget( dt );
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:QuietEditorPane.java

示例3: remove

import java.awt.dnd.DropTarget; //导入依赖的package包/类
void remove( CategoryDescriptor descriptor ) {
    ArrayList<DragGestureRecognizer> recognizersToRemove = new ArrayList<DragGestureRecognizer>( 2 );
    for( Iterator<DragGestureRecognizer> i=recognizers.iterator(); i.hasNext(); ) {
        DragGestureRecognizer dgr = i.next();
        if( dgr.getComponent() == descriptor.getButton()
            || dgr.getComponent() == descriptor.getList() ) {
            recognizersToRemove.add( dgr );
            dgr.removeDragGestureListener( this );
        }
    }
    recognizers.removeAll( recognizersToRemove );
    
    ArrayList<DropTarget> dropTargetsToRemove = new ArrayList<DropTarget>( 2 );
    for( Iterator<DropTarget> i=dropTargets.iterator(); i.hasNext(); ) {
        DropTarget dt = i.next();
        if( dt.getComponent() == descriptor.getButton()
            || dt.getComponent() == descriptor.getList() ) {
            dropTargetsToRemove.add( dt );
            dt.removeDropTargetListener( this );
        }
    }
    dropTargets.removeAll( dropTargetsToRemove );
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:DnDSupport.java

示例4: addDropTarget

import java.awt.dnd.DropTarget; //导入依赖的package包/类
@Override
public void addDropTarget(DropTarget dt) {
    LWWindowPeer winPeer = getWindowPeerOrSelf();
    if (winPeer != null && winPeer != this) {
        // We need to register the DropTarget in the
        // peer of the window ancestor of the component
        winPeer.addDropTarget(dt);
    } else {
        synchronized (dropTargetLock) {
            // 10-14-02 VL: Windows WComponentPeer would add (or remove) the drop target only
            // if it's the first (or last) one for the component. Otherwise this call is a no-op.
            if (++fNumDropTargets == 1) {
                // Having a non-null drop target would be an error but let's check just in case:
                if (fDropTarget != null) {
                    throw new IllegalStateException("Current drop target is not null");
                }
                // Create a new drop target:
                fDropTarget = LWToolkit.getLWToolkit().createDropTarget(dt, target, this);
            }
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:LWComponentPeer.java

示例5: postInitComponents

import java.awt.dnd.DropTarget; //导入依赖的package包/类
private void postInitComponents () {
    Containers.initNotify ();
    updateTable = createTabForModel(new UpdateTableModel(units));
    availableTable = createTabForModel(new AvailableTableModel (units));
    final LocalDownloadSupport localDownloadSupport = new LocalDownloadSupport();
    final LocallyDownloadedTableModel localTM = new LocallyDownloadedTableModel(localDownloadSupport);
    localTable = createTabForModel(localTM);
    installedTable = createTabForModel(new InstalledTableModel(units));

    DropTargetListener l = new LocallDownloadDnD(localDownloadSupport, localTM, this);
    final DropTarget dt = new DropTarget(null, l);
    dt.setActive(true);
    this.setDropTarget(dt);


    final SettingsTab tab = new SettingsTab(this);
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            tpTabs.add(tab, INDEX_OF_SETTINGS_TAB);
            tpTabs.setTitleAt(INDEX_OF_SETTINGS_TAB, tab.getDisplayName());
        }
    });
    setWaitingState(true);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:PluginManagerUI.java

示例6: removeDropTarget

import java.awt.dnd.DropTarget; //导入依赖的package包/类
@Override
public void removeDropTarget(DropTarget dt) {
    LWWindowPeer winPeer = getWindowPeerOrSelf();
    if (winPeer != null && winPeer != this) {
        // We need to unregister the DropTarget in the
        // peer of the window ancestor of the component
        winPeer.removeDropTarget(dt);
    } else {
        synchronized (dropTargetLock){
            // 10-14-02 VL: Windows WComponentPeer would add (or remove) the drop target only
            // if it's the first (or last) one for the component. Otherwise this call is a no-op.
            if (--fNumDropTargets == 0) {
                // Having a null drop target would be an error but let's check just in case:
                if (fDropTarget != null) {
                    // Dispose of the drop target:
                    fDropTarget.dispose();
                    fDropTarget = null;
                } else
                    System.err.println("CComponent.removeDropTarget(): current drop target is null.");
            }
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:24,代码来源:LWComponentPeer.java

示例7: CDropTarget

import java.awt.dnd.DropTarget; //导入依赖的package包/类
private CDropTarget(DropTarget dropTarget, Component component, ComponentPeer peer) {
    super();

    fDropTarget = dropTarget;
    fComponent = component;
    fPeer = peer;

    long nativePeer = CPlatformWindow.getNativeViewPtr(((LWComponentPeer) peer).getPlatformWindow());
    if (nativePeer == 0L) return; // Unsupported for a window without a native view (plugin)

    // Create native dragging destination:
    fNativeDropTarget = this.createNativeDropTarget(dropTarget, component, peer, nativePeer);
    if (fNativeDropTarget == 0) {
        throw new IllegalStateException("CDropTarget.createNativeDropTarget() failed.");
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:17,代码来源:CDropTarget.java

示例8: addDropTarget

import java.awt.dnd.DropTarget; //导入依赖的package包/类
@Override
public void addDropTarget(DropTarget dt) {
    LWWindowPeer winPeer = getWindowPeerOrSelf();
    if (winPeer != null && winPeer != this) {
        // We need to register the DropTarget in the
        // peer of the window ancestor of the component
        winPeer.addDropTarget(dt);
    } else {
        synchronized (dropTargetLock) {
            // 10-14-02 VL: Windows WComponentPeer would add (or remove) the drop target only
            // if it's the first (or last) one for the component. Otherwise this call is a no-op.
            if (++fNumDropTargets == 1) {
                // Having a non-null drop target would be an error but let's check just in case:
                if (fDropTarget != null)
                    System.err.println("CComponent.addDropTarget(): current drop target is non-null.");

                // Create a new drop target:
                fDropTarget = CDropTarget.createDropTarget(dt, target, this);
            }
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:23,代码来源:LWComponentPeer.java

示例9: initAndShowUI

import java.awt.dnd.DropTarget; //导入依赖的package包/类
private static void initAndShowUI() {
    frame = new JFrame("Test frame");

    frame.setSize(SIZE, SIZE);
    frame.setLocationRelativeTo(null);
    final JTextArea jta = new JTextArea();
    jta.setBackground(Color.RED);
    frame.add(jta);
    jta.setText("1234567890");
    jta.setFont(jta.getFont().deriveFont(150f));
    jta.setDragEnabled(true);
    jta.selectAll();
    jta.setDropTarget(new DropTarget(jta, DnDConstants.ACTION_COPY,
                                     new TestdropTargetListener()));
    jta.addMouseListener(new TestMouseAdapter());
    frame.setVisible(true);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:18,代码来源:MissingDragExitEventTest.java

示例10: EditorRuler

import java.awt.dnd.DropTarget; //导入依赖的package包/类
/**
 * Constructs a new ruler for the specified graph and orientation.
 * 
 * @param graph The graph to create the ruler for.
 * @param orientation The orientation to use for the ruler.
 */
public EditorRuler(mxGraphComponent graphComponent, int orientation) {
  this.orientation = orientation;
  this.graphComponent = graphComponent;
  updateIncrementAndUnits();

  graphComponent.getGraph().getView().addListener(mxEvent.SCALE, repaintHandler);
  graphComponent.getGraph().getView().addListener(mxEvent.TRANSLATE, repaintHandler);
  graphComponent.getGraph().getView().addListener(mxEvent.SCALE_AND_TRANSLATE, repaintHandler);

  graphComponent.getGraphControl().addMouseMotionListener(this);

  DropTarget dropTarget = graphComponent.getDropTarget();

  try {
    if (dropTarget != null) {
      dropTarget.addDropTargetListener(this);
    }
  } catch (TooManyListenersException tmle) {
    // should not happen... swing drop target is multicast
  }

  setBorder(BorderFactory.createLineBorder(Color.black));
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:30,代码来源:EditorRuler.java

示例11: configureGlassLayer

import java.awt.dnd.DropTarget; //导入依赖的package包/类
private void configureGlassLayer() {
    try {
        glassLayer.setDropTarget(new DropTarget());
        glassLayer.getDropTarget().addDropTargetListener(new GlassLayerDropTargetListener());
    } catch (TooManyListenersException ex) {
        ex.printStackTrace();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:MenuEditLayer.java

示例12: add

import java.awt.dnd.DropTarget; //导入依赖的package包/类
void add( CategoryDescriptor descriptor ) {
    CategoryList list = descriptor.getList();
    list.setTransferHandler( null );
    list.setDragEnabled(false);
    recognizers.add( DragSource.getDefaultDragSource().createDefaultDragGestureRecognizer( list, DnDConstants.ACTION_MOVE, this ) );
    dropTargets.add( new DropTarget( list, this ) );
    
    CategoryButton button = descriptor.getButton();
    button.setTransferHandler( null );
    recognizers.add( DragSource.getDefaultDragSource().createDefaultDragGestureRecognizer( button, DnDConstants.ACTION_MOVE, this ) );
    dropTargets.add( new DropTarget( button, this ) );
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:DnDSupport.java

示例13: createDropTargetContext

import java.awt.dnd.DropTarget; //导入依赖的package包/类
private DropTargetContext createDropTargetContext() throws SecurityException, NoSuchMethodException, IllegalArgumentException,
        InstantiationException, IllegalAccessException, InvocationTargetException {
    Constructor<DropTargetContext> c = DropTargetContext.class.getDeclaredConstructor(DropTarget.class);
    c.setAccessible(true);
    DropTargetContext inst = c.newInstance(dest.getDropTarget());
    inst.addNotify(createDropTargetContextPeer());
    return inst;
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:9,代码来源:DnDHandler.java

示例14: UMLDiagramPanel

import java.awt.dnd.DropTarget; //导入依赖的package包/类
public UMLDiagramPanel(DiagramEditor _editorLoader) {
  diagramEditor = _editorLoader;
  isOpenGLEnabled = Boolean.parseBoolean(System.getProperty("sun.java2d.opengl"));
  if (!isOpenGLEnabled) {
    logger.warn("OpenGL is not enabled, there could be some performance and quality issues. It can be enabled using -Dsun.java2d.opengl=true runtime argument.");
  }
  // we are going to listen mouse clicks and movements for various operations
  this.addMouseListener(this);
  this.addMouseMotionListener(this);
  this.addMouseWheelListener(this);
  this.setDropTarget(new DropTarget(this, DnDConstants.ACTION_COPY_OR_MOVE, new DropTargetAdapter() {
    @Override
    public void drop(DropTargetDropEvent dtde) {
      if (dtde.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
        try {
          dtde.acceptDrop(dtde.getDropAction());
          Object transferData = dtde.getTransferable().getTransferData(DataFlavor.javaFileListFlavor);
          if (transferData != null && transferData instanceof List) {
            List files = (List) transferData;
            if (files.size() > 0) {
              diagramEditor.open((File) files.get(0));
              dtde.dropComplete(true);
            }
          }
        } catch (Exception e) {
          logger.error(e.getMessage(), e);
          InformationDialog.display(e.getMessage());
        }
      } else {
        dtde.rejectDrop();
      }
    }
  }));
  this.setBackground(Color.WHITE);
}
 
开发者ID:onprom,项目名称:onprom,代码行数:36,代码来源:UMLDiagramPanel.java

示例15: View

import java.awt.dnd.DropTarget; //导入依赖的package包/类
public View(Board b, SetupStack s) {
  myBoard = b;
  myGrid = b.getGrid();
  myStack = s;
  slot = myStack.getTopPiece();
  if (slot != null) {
    myPiece = slot.getPiece();
  }
  new DropTarget(this, DnDConstants.ACTION_MOVE, this);
  ds.createDefaultDragGestureRecognizer(this,
    DnDConstants.ACTION_MOVE, this);
  setFocusTraversalKeysEnabled(false);
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:14,代码来源:SetupStack.java


注:本文中的java.awt.dnd.DropTarget类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。