Java Code Examples for javax.swing.JComponent#setAutoscrolls()

The following examples show how to use javax.swing.JComponent#setAutoscrolls() . These examples are extracted from open source projects. 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
/**
 * {@inheritDoc}
 */
public void dragGestureRecognized(DragGestureEvent dge) {
    JComponent c = (JComponent)dge.getComponent();
    DefaultTransferHandler th
        = (DefaultTransferHandler)c.getTransferHandler();
    Transferable t = th.createTransferable(c);
    if (t == null) {
        logger.warning("Unable to create transferable for: " + dge);
        th.exportDone(c, null, NONE);
        return;
    }

    this.scrolls = c.getAutoscrolls();
    c.setAutoscrolls(false);
    try {
        Cursor cursor = getCursor(c);
        dge.startDrag(cursor, t, this);
    } catch (RuntimeException re) {
        c.setAutoscrolls(this.scrolls);
    }
}
 
Example 2
Source Project: nanoleaf-desktop   File: ComponentResizer.java    License: MIT License 5 votes vote down vote up
@Override
public void mousePressed(MouseEvent e)
{
	//	The mouseMoved event continually updates this variable

	if (direction == 0) return;

	//  Setup for resizing. All future dragging calculations are done based
	//  on the original bounds of the component and mouse pressed location.

	resizing = true;

	Component source = e.getComponent();
	pressed = e.getPoint();
	SwingUtilities.convertPointToScreen(pressed, source);
	bounds = source.getBounds();

	//  Making sure autoscrolls is false will allow for smoother resizing
	//  of components

	if (source instanceof JComponent)
	{
		JComponent jc = (JComponent)source;
		autoscrolls = jc.getAutoscrolls();
		jc.setAutoscrolls( false );
	}
}
 
Example 3
/**
 * {@inheritDoc}
 */
public void dragDropEnd(DragSourceDropEvent dsde) {
    DragSourceContext dsc = dsde.getDragSourceContext();
    JComponent c = (JComponent)dsc.getComponent();

    if (dsde.getDropSuccess()) {
        ((DefaultTransferHandler)c.getTransferHandler()).exportDone(c,
            dsc.getTransferable(), dsde.getDropAction());
    } else {
        ((DefaultTransferHandler)c.getTransferHandler()).exportDone(c,
            null, NONE);
    }
    c.setAutoscrolls(scrolls);
}
 
Example 4
@Override
public void mousePressed(MouseEvent e) {
    //  The mouseMoved event continually updates this variable

    if (direction == 0) {
        return;
    }

    //  Setup for resizing. All future dragging calculations are done based
    //  on the original bounds of the component and mouse pressed location.

    resizing = true;

    Component source = e.getComponent();
    pressed = e.getPoint();
    SwingUtilities.convertPointToScreen(pressed, source);
    bounds = source.getBounds();

    //  Making sure autoscrolls is false will allow for smoother resizing
    //  of components

    if (source instanceof JComponent) {
        JComponent jc = (JComponent) source;
        autoscrolls = jc.getAutoscrolls();
        jc.setAutoscrolls(false);
    }
}
 
Example 5
private void setupForDragging(MouseEvent e) {
        source.addMouseMotionListener(this);
        potentialDrag = true;

        //  Determine the component that will ultimately be moved

        if (destinationComponent != null) {
            destination = destinationComponent;
        }

//        if (destination instanceof MainView) {
//            final MainView gui = (MainView) destination;
//            if (gui.isMaximized()) {
//                return;
//            }
//        }

        pressed = e.getLocationOnScreen();
        location = destination.getLocation();

        if (changeCursor) {
            originalCursor = source.getCursor();
            source.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));

        }

        //  Making sure autoscrolls is false will allow for smoother dragging of
        //  individual components

        if (destination instanceof JComponent) {
            JComponent jc = (JComponent) destination;
            autoscrolls = jc.getAutoscrolls();
            jc.setAutoscrolls(false);
        }
    }
 
Example 6
/**
 * as the operation completes
 */
@Override
public void dragDropEnd(DragSourceDropEvent dsde) {
	DragSourceContext dsc = dsde.getDragSourceContext();
	JComponent c = (JComponent) dsc.getComponent();
	if (dsde.getDropSuccess()) {
		((AbstractPatchedTransferHandler) c.getTransferHandler()).exportDone(c, dsc.getTransferable(),
				dsde.getDropAction());
	} else {
		((AbstractPatchedTransferHandler) c.getTransferHandler()).exportDone(c, dsc.getTransferable(), NONE);
	}
	c.setAutoscrolls(scrolls);
	fireDragEnded();
}
 
Example 7
private void setupForDragging(MouseEvent e)
{
	source.addMouseMotionListener( this );
	potentialDrag = true;

	//  Determine the component that will ultimately be moved

	if (destinationComponent != null)
	{
		destination = destinationComponent;
	}
	else if (destinationClass == null)
	{
		destination = source;
	}
	else  //  forward events to destination component
	{
		destination = SwingUtilities.getAncestorOfClass(destinationClass, source);
	}

	pressed = e.getLocationOnScreen();
	location = destination.getLocation();

	if (changeCursor)
	{
		originalCursor = source.getCursor();
		source.setCursor( Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR) );
	}

	//  Making sure autoscrolls is false will allow for smoother dragging of
	//  individual components

	if (destination instanceof JComponent)
	{
		JComponent jc = (JComponent)destination;
		autoscrolls = jc.getAutoscrolls();
		jc.setAutoscrolls( false );
	}
}
 
Example 8
Source Project: SikuliX1   File: ComponentMover.java    License: MIT License 2 votes vote down vote up
private void setupForDragging(MouseEvent e)

   {

      source.addMouseMotionListener( this );


      //  Determine the component that will ultimately be moved


      if (destinationComponent != null)

      {

         destination = destinationComponent;

      }

      else if (destinationClass == null)

      {

         destination = source;

      }

      else  //  forward events to destination component

      {

         destination = SwingUtilities.getAncestorOfClass(destinationClass, source);

      }


      pressed = e.getLocationOnScreen();

      if (destination instanceof Visual){
         location = ((Visual) destination).getActualLocation();
      }else{
         location = destination.getLocation();
      }


      if (changeCursor)

      {

         originalCursor = source.getCursor();

         source.setCursor( Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR) );

      }


      //  Making sure autoscrolls is false will allow for smoother dragging of

      //  individual components


      if (destination instanceof JComponent)

      {

         JComponent jc = (JComponent)destination;

         autoscrolls = jc.getAutoscrolls();

         jc.setAutoscrolls( false );

      }

   }