Java Code Examples for java.awt.dnd.DragSource#createDefaultDragGestureRecognizer()

The following examples show how to use java.awt.dnd.DragSource#createDefaultDragGestureRecognizer() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PaletteButton.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
public PaletteButton( final ElementMetaData elementMetaData,
                      final ReportDesignerContext context ) {
  if ( elementMetaData == null ) {
    throw new NullPointerException();
  }
  elementName = elementMetaData.getName();
  putClientProperty( "hideActionText", Boolean.TRUE ); // NON-NLS

  final DragSource dragSource = new DragSource();

  dragSource.createDefaultDragGestureRecognizer( this, DnDConstants.ACTION_COPY, this );

  final InsertElementAction action = new AlwaysActiveInsertElementAction( elementMetaData );
  action.setReportDesignerContext( context );
  setAction( action );

  final Image icon = elementMetaData.getIcon( Locale.getDefault(), BeanInfo.ICON_COLOR_16x16 );
  if ( icon != null ) {
    setIcon( new ImageIcon( icon ) );
  } else {
    setText( elementMetaData.getDisplayName( Locale.getDefault() ) );
  }
  setToolTipText( elementMetaData.getDescription( Locale.getDefault() ) );
  setFocusable( false );
  setBorder( BorderFactory.createEmptyBorder( 4, 4, 4, 4 ) );
}
 
Example 2
Source File: SourcePanel.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public SourcePanel () {
    setPreferredSize(new Dimension(200, 200));
    DragSource defaultDragSource =
            DragSource.getDefaultDragSource();
    defaultDragSource.createDefaultDragGestureRecognizer(this,
            DnDConstants.ACTION_COPY_OR_MOVE, dragGestureListener);
    setBackground(Color.RED);
}
 
Example 3
Source File: SourcePanel.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public SourcePanel () {
    setPreferredSize(new Dimension(200, 200));
    DragSource defaultDragSource =
            DragSource.getDefaultDragSource();
    defaultDragSource.createDefaultDragGestureRecognizer(this,
            DnDConstants.ACTION_COPY_OR_MOVE, dragGestureListener);
    setBackground(Color.RED);
}
 
Example 4
Source File: SourcePanel.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public SourcePanel() {
    setPreferredSize(new Dimension(200, 200));
    DragSource defaultDragSource =
            DragSource.getDefaultDragSource();
    defaultDragSource.createDefaultDragGestureRecognizer(this,
            DnDConstants.ACTION_COPY_OR_MOVE, dragGestureListener);
    setBackground(Color.RED);
}
 
Example 5
Source File: SourcePanel.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public SourcePanel () {
    setPreferredSize(new Dimension(200, 200));
    DragSource defaultDragSource =
            DragSource.getDefaultDragSource();
    defaultDragSource.createDefaultDragGestureRecognizer(this,
            DnDConstants.ACTION_COPY_OR_MOVE, dragGestureListener);
    setBackground(Color.RED);
}
 
Example 6
Source File: DragManager.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Creates a new instance of SplashDnDSupport */
DragManager(JComponent component) {
    this.component = component;
    dSource =  new DragSource();
    dRecognizer = dSource.createDefaultDragGestureRecognizer(this.component,DnDConstants.ACTION_MOVE,this);
    dTarget = new DropTarget(this.component,DnDConstants.ACTION_MOVE,this);
    component.addMouseMotionListener(this);
    oCursor = component.getCursor();
}
 
Example 7
Source File: IndexedCustomizer.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Creates drag source with asociated list where drag
* will take place.
* Also creates the default gesture and asociates this with
* given component */
IndexedDragSource(JList comp) {
    this.comp = comp;

    // initialize gesture
    DragSource ds = DragSource.getDefaultDragSource();
    ds.createDefaultDragGestureRecognizer(comp, DnDConstants.ACTION_MOVE, this);
}
 
Example 8
Source File: AbstractTreeTransferHandler.java    From binnavi with Apache License 2.0 5 votes vote down vote up
protected AbstractTreeTransferHandler(final DNDTree tree, final int action, final boolean drawIcon) {
  this.tree = tree;
  drawImage = drawIcon;
  dragSource = new DragSource();
  dragSource.createDefaultDragGestureRecognizer(tree, action, this);
  dropTarget = new DropTarget(tree, action, this);
}
 
Example 9
Source File: JTreeUtil.java    From Logisim with GNU General Public License v3.0 5 votes vote down vote up
protected TreeTransferHandler(JTree tree, JTreeDragController controller, int action, boolean drawIcon) {
	this.tree = tree;
	this.controller = controller;
	drawImage = drawIcon;
	dragSource = new DragSource();
	dragSource.createDefaultDragGestureRecognizer(tree, action, this);
}
 
Example 10
Source File: SourcePanel.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public SourcePanel () {
    setPreferredSize(new Dimension(200, 200));
    DragSource defaultDragSource =
            DragSource.getDefaultDragSource();
    defaultDragSource.createDefaultDragGestureRecognizer(this,
            DnDConstants.ACTION_COPY_OR_MOVE, dragGestureListener);
    setBackground(Color.RED);
}
 
Example 11
Source File: SourcePanel.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public SourcePanel () {
    setPreferredSize(new Dimension(200, 200));
    DragSource defaultDragSource =
            DragSource.getDefaultDragSource();
    defaultDragSource.createDefaultDragGestureRecognizer(this,
            DnDConstants.ACTION_COPY_OR_MOVE, dragGestureListener);
    setBackground(Color.RED);
}
 
Example 12
Source File: MissingEventsOnModalDialogTest.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    Frame sourceFrame = createFrame("Source Frame", 0, 0);
    Frame targetFrame = createFrame("Target Frame", 250, 250);

    DragSource defaultDragSource
            = DragSource.getDefaultDragSource();
    defaultDragSource.createDefaultDragGestureRecognizer(sourceFrame,
            DnDConstants.ACTION_COPY_OR_MOVE,
            new TestDragGestureListener());
    new DropTarget(targetFrame, DnDConstants.ACTION_COPY_OR_MOVE,
            new TestDropTargetListener(targetFrame));

    Robot robot = new Robot();
    robot.setAutoDelay(50);

    sourceFrame.toFront();
    robot.waitForIdle();

    Point point = getCenterPoint(sourceFrame);
    robot.mouseMove(point.x, point.y);
    robot.waitForIdle();

    mouseDragAndDrop(robot, point, getCenterPoint(targetFrame));

    long time = System.currentTimeMillis() + 200;

    while (!passed) {
        if (time < System.currentTimeMillis()) {
            sourceFrame.dispose();
            targetFrame.dispose();
            throw new RuntimeException("Mouse clicked event is lost!");
        }
        Thread.sleep(10);
    }
    sourceFrame.dispose();
    targetFrame.dispose();
}
 
Example 13
Source File: SourcePanel.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public SourcePanel () {
    setPreferredSize(new Dimension(200, 200));
    DragSource defaultDragSource =
            DragSource.getDefaultDragSource();
    defaultDragSource.createDefaultDragGestureRecognizer(this,
            DnDConstants.ACTION_COPY_OR_MOVE, dragGestureListener);
    setBackground(Color.RED);
}
 
Example 14
Source File: OutputTree.java    From swing_library with MIT License 5 votes vote down vote up
/**
 * 
 * @param treeModel
 * @param cPanel
 */
public OutputTree(OutputTreeModel treeModel) {
	this.setModel(treeModel);

	DragSource dragSource = DragSource.getDefaultDragSource();
	dragSource.createDefaultDragGestureRecognizer(this,
			DnDConstants.ACTION_COPY, this);
}
 
Example 15
Source File: SourcePanel.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public SourcePanel() {
    setPreferredSize(new Dimension(200, 200));
    DragSource defaultDragSource =
            DragSource.getDefaultDragSource();
    defaultDragSource.createDefaultDragGestureRecognizer(this,
            DnDConstants.ACTION_COPY_OR_MOVE, dragGestureListener);
    setBackground(Color.RED);
}
 
Example 16
Source File: SourcePanel.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public SourcePanel () {
    setPreferredSize(new Dimension(200, 200));
    DragSource defaultDragSource =
            DragSource.getDefaultDragSource();
    defaultDragSource.createDefaultDragGestureRecognizer(this,
            DnDConstants.ACTION_COPY_OR_MOVE, dragGestureListener);
    setBackground(Color.RED);
}
 
Example 17
Source File: SourcePanel.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public SourcePanel() {
    setPreferredSize(new Dimension(200, 200));
    DragSource defaultDragSource =
            DragSource.getDefaultDragSource();
    defaultDragSource.createDefaultDragGestureRecognizer(this,
            DnDConstants.ACTION_COPY_OR_MOVE, dragGestureListener);
    setBackground(Color.RED);
}
 
Example 18
Source File: EntityPallet.java    From jaamsim with Apache License 2.0 5 votes vote down vote up
private EntityPallet() {

		super( "Model Builder" );
		setType(Type.UTILITY);
		setAutoRequestFocus(false);
		// Make the x button do the same as the close button
		setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
		addWindowListener(FrameBox.getCloseListener("ShowModelBuilder"));

		tree = new MyTree();
		tree.setRootVisible(false);
		tree.setShowsRootHandles(true);
		DragSource dragSource = new DragSource();
		dragSource.createDefaultDragGestureRecognizer(tree, DnDConstants.ACTION_COPY, this);

		top = new DefaultMutableTreeNode();
		treeModel = new DefaultTreeModel(top);
		tree.setModel(treeModel);
		tree.getSelectionModel().setSelectionMode( TreeSelectionModel.SINGLE_TREE_SELECTION );

		// Create the tree scroll pane and add the tree to it
		treeView = new JScrollPane( tree );
		getContentPane().add( treeView );

		tree.setRowHeight(25);
		tree.setCellRenderer(new TreeCellRenderer());
		ToolTipManager.sharedInstance().registerComponent(tree);
		ToolTipManager.sharedInstance().setDismissDelay(600000);

		addComponentListener(FrameBox.getSizePosAdapter(this, "ModelBuilderSize", "ModelBuilderPos"));
	}
 
Example 19
Source File: SourcePanel.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public SourcePanel () {
    setPreferredSize(new Dimension(200, 200));
    DragSource defaultDragSource =
            DragSource.getDefaultDragSource();
    defaultDragSource.createDefaultDragGestureRecognizer(this,
            DnDConstants.ACTION_COPY_OR_MOVE, dragGestureListener);
    setBackground(Color.RED);
}
 
Example 20
Source File: DragDropList.java    From constellation with Apache License 2.0 4 votes vote down vote up
public MyDragListener(final DragDropList list) {
    this.list = list;
    ds = new DragSource();
    ds.createDefaultDragGestureRecognizer(list, DnDConstants.ACTION_MOVE, this);
}