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

The following examples show how to use javax.swing.JComponent#getAutoscrolls() . 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: DefaultTransferHandler.java    From freecol with GNU General Public License v2.0 6 votes vote down vote up
/**
 * {@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 File: ComponentResizer.java    From nanoleaf-desktop with 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
Source File: ComponentResizer.java    From 07kit with GNU General Public License v3.0 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 4
Source File: ComponentMover.java    From 07kit with GNU General Public License v3.0 5 votes vote down vote up
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 5
Source File: ComponentMover.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
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 6
Source File: ComponentMover.java    From SikuliX1 with 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 );

      }

   }