Java Code Examples for java.awt.event.KeyEvent#isShiftDown()

The following examples show how to use java.awt.event.KeyEvent#isShiftDown() . 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: KeyStroker.java    From tn5250j with GNU General Public License v2.0 6 votes vote down vote up
public void setAttributes(KeyEvent ke, boolean isAltGr) {

    keyCode = ke.getKeyCode();
    isShiftDown = ke.isShiftDown();
    isControlDown = ke.isControlDown();
    isAltDown = ke.isAltDown();
    isAltGrDown = isAltGr;
    location = ke.getKeyLocation();

    hashCode = keyCode +
        (isShiftDown ? 1 : 0) +
        (isControlDown ? 1 : 0) +
        (isAltDown ? 1 : 0) +
        (isAltGrDown ? 1 : 0) +
        location;
  }
 
Example 2
Source File: DisplayCanvas.java    From TrakEM2 with GNU General Public License v3.0 6 votes vote down vote up
private void handleHide(final KeyEvent ke) {
	if (ke.isAltDown() && !ke.isShiftDown()) {
		// show hidden
		Display.updateCheckboxes(display.getLayer().getParent().setAllVisible(false), DisplayablePanel.VISIBILITY_STATE);
		//Display.repaint(display.getLayer());
		Display.update(display.getLayer());
		ke.consume();
		return;
	}
	if (ke.isShiftDown()) {
		// hide deselected
		display.hideDeselected(ke.isAltDown());
		ke.consume();
		return;
	}
	// else, hide selected
	display.getSelection().setVisible(false);
	Display.update(display.getLayer());
	ke.consume();
}
 
Example 3
Source File: KeyGetter.java    From tn5250j with GNU General Public License v2.0 6 votes vote down vote up
void processVTKeyTyped(KeyEvent e){

       displayInfo(e);
      int keycode = e.getKeyCode();
      if (e.isAltDown() ||
         e.isShiftDown() ||
         e.isControlDown() ||
         e.isActionKey() ||
         keycode == KeyEvent.VK_CONTROL) {

         keyevent = e;
//            displayInfo(e,"Released added ");
         dialog.setVisible(false);
         dialog.dispose();
      }

   }
 
Example 4
Source File: CropTool.java    From Pixelitor with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void otherKeyPressed(KeyEvent e) {
    if (e.getKeyCode() == KeyEvent.VK_ENTER) {
        executeCropCommand();
        e.consume();
    } else if (e.getKeyCode() == KeyEvent.VK_O) {
        if (e.isControlDown()) {
            // ignore Ctrl-O see issue #81
            return;
        }
        if (e.isShiftDown()) {
            // Shift-O: change the orientation
            // within the current composition guide family
            if (state == TRANSFORM) {
                int o = compositionGuide.getOrientation();
                compositionGuide.setOrientation(o + 1);
                OpenImages.repaintActive();
                e.consume();
            }
        } else {
            // O: advance to the next composition guide
            selectTheNextCompositionGuide();
            e.consume();
        }
    }
}
 
Example 5
Source File: ConsoleDevice.java    From basicv2 with The Unlicense 5 votes vote down vote up
@Override
public void keyPressed(KeyEvent e) {
	if (e.isControlDown() && e.isShiftDown()) {
		if (!pressed) {
			toggleFontMode();
			pressed = true;
		}
	}
}
 
Example 6
Source File: TextSearchBar.java    From pumpernickel with MIT License 5 votes vote down vote up
@Override
public void keyPressed(KeyEvent e) {
	if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
		setVisible(false);
		e.consume();
	} else if (e.getKeyCode() == KeyEvent.VK_ENTER
			&& e.isShiftDown() == false) {
		nextButton.doClick();
		e.consume();
	} else if (e.getKeyCode() == KeyEvent.VK_ENTER && e.isShiftDown()) {
		prevButton.doClick();
		e.consume();
	}
}
 
Example 7
Source File: JColorPickerPanel.java    From pumpernickel with MIT License 5 votes vote down vote up
@Override
public void keyPressed(KeyEvent e) {
	int dx = 0;
	int dy = 0;
	if (e.getKeyCode() == KeyEvent.VK_LEFT) {
		dx = -1;
	} else if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
		dx = 1;
	} else if (e.getKeyCode() == KeyEvent.VK_UP) {
		dy = -1;
	} else if (e.getKeyCode() == KeyEvent.VK_DOWN) {
		dy = 1;
	}
	int multiplier = 1;
	if (e.isShiftDown() && e.isAltDown()) {
		multiplier = 10;
	} else if (e.isShiftDown() || e.isAltDown()) {
		multiplier = 5;
	}
	if (dx != 0 || dy != 0) {
		int size = Math.min(
				MAX_SIZE,
				Math.min(getWidth() - imagePadding.left
						- imagePadding.right, getHeight()
						- imagePadding.top - imagePadding.bottom));

		int offsetX = getWidth() / 2 - size / 2;
		int offsetY = getHeight() / 2 - size / 2;
		mouseListener.mousePressed(new MouseEvent(
				JColorPickerPanel.this, MouseEvent.MOUSE_PRESSED,
				System.currentTimeMillis(), 0, point.x + multiplier
						* dx + offsetX, point.y + multiplier * dy
						+ offsetY, 1, false));
	}
}
 
Example 8
Source File: KeyStroker.java    From tn5250j with GNU General Public License v2.0 5 votes vote down vote up
public boolean equals(KeyEvent ke, boolean altGrDown) {

    return (keyCode == ke.getKeyCode() &&
        isShiftDown == ke.isShiftDown() &&
        isControlDown == ke.isControlDown() &&
        isAltDown == ke.isAltDown() &&
        isAltGrDown == altGrDown &&
        location == ke.getKeyLocation());
  }
 
Example 9
Source File: Editor.java    From brModelo with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void keyPressed(KeyEvent e) {
    if (diagramaAtual != null) {
        switch (e.getKeyCode()) {
            case KeyEvent.VK_LEFT:
            case KeyEvent.VK_RIGHT:
            case KeyEvent.VK_UP:
            case KeyEvent.VK_DOWN:
            case KeyEvent.VK_ESCAPE:
            case KeyEvent.VK_ENTER:
                diagramaAtual.ProcesseTeclas(e);
                break;
            case KeyEvent.VK_DELETE:
                if (diagramaAtual != null) {
                    diagramaAtual.deleteSelecao();
                    e.consume();
                }
                break;
            case KeyEvent.VK_TAB:
                if (e.isControlDown()) {
                    if (e.isShiftDown()) {
                        if (diagramaAtual.SelecioneAnterior()) {
                            e.consume();
                        }
                    } else if (diagramaAtual.SelecioneProximo()) {
                        e.consume();
                    }
                } else {
                    transferFocus();
                }
                break;
        }
    }
}
 
Example 10
Source File: ClarifyingKeyListener.java    From SNT with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void keyPressed(final KeyEvent e) {

	final int keyCode = e.getKeyCode();

	if (e.isShiftDown() && (e.isControlDown() || e.isAltDown()) && (keyCode == KeyEvent.VK_A)) {
		IJ.error("You seem to be trying to start Sholl analysis, but the focus is on the wrong window.\n"
				+ "Bring the (2D) image window to the foreground and try again.");
		e.consume();
	}
}
 
Example 11
Source File: Window.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * Implements a debugging hook -- checks to see if
 * the user has typed <i>control-shift-F1</i>.  If so,
 * the list of child windows is dumped to {@code System.out}.
 * @param e  the keyboard event
 */
void preProcessKeyEvent(KeyEvent e) {
    // Dump the list of child windows to System.out if debug is enabled.
    if (DebugSettings.getInstance().getBoolean("on", false)) {
        if (e.isActionKey() && e.getKeyCode() == KeyEvent.VK_F1 &&
                e.isControlDown() && e.isShiftDown() &&
                e.getID() == KeyEvent.KEY_PRESSED) {
            list(System.out, 0);
        }
    }
}
 
Example 12
Source File: RunPane.java    From constellation with Apache License 2.0 5 votes vote down vote up
@Override
public void keyPressed(final KeyEvent event) {
    final int keyCode = event.getKeyCode();
    // Avoid the control key so we don't interfere with ^S for save, for example.
    final boolean isCtrl = event.isControlDown();
    final boolean isShift = event.isShiftDown();
}
 
Example 13
Source File: RegionSelector.java    From AndroidDesignPreview with Apache License 2.0 5 votes vote down vote up
public void keyPressed(KeyEvent keyEvent) {
    if (keyEvent.getKeyCode() == KeyEvent.VK_ESCAPE) {
        showWindow(false);
        return;
    }

    Point newLocation = getLocation();

    int val = keyEvent.isShiftDown() ? 10 : 1;

    switch (keyEvent.getKeyCode()) {
        case KeyEvent.VK_UP:
            newLocation.y -= val;
            break;
        case KeyEvent.VK_LEFT:
            newLocation.x -= val;
            break;
        case KeyEvent.VK_DOWN:
            newLocation.y += val;
            break;
        case KeyEvent.VK_RIGHT:
            newLocation.x += val;
            break;
        default:
            return;
    }

    region.setLocation(newLocation);
    setRegion(region);
    delayedTrySaveFrameConfig();
}
 
Example 14
Source File: OverlayRenderer.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void keyPressed(KeyEvent e)
{
	if (e.isAltDown())
	{
		inOverlayManagingMode = true;
	}

	if (e.isShiftDown() && runeLiteConfig.menuEntryShift())
	{
		inMenuEntryMode = true;
	}
}
 
Example 15
Source File: KeyboardMenuNavigator.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void keyPressed(KeyEvent e) {
    if(e.getKeyCode() == KeyEvent.VK_DOWN) {
        selectOffsetMenuItem(+1);
    }
    if(e.getKeyCode() == KeyEvent.VK_UP) {
        selectOffsetMenuItem(-1);
    }
    if(e.getKeyCode() == KeyEvent.VK_LEFT) {
        selectOffsetMenu(-1);
    }
    if(e.getKeyCode() == KeyEvent.VK_RIGHT) {
        selectOffsetMenu(+1);
    }
    
    if(e.getKeyCode() == KeyEvent.VK_SPACE) {
        startEditing();
    }
    // #116961: start inplace editing when F2 key is pressed on a menu
    if(e.getKeyCode() == KeyEvent.VK_F2) {
        startEditing();
    }
    //we aren't getting tabs for some reason
    if(e.getKeyCode() == KeyEvent.VK_A) {
        if(e.isShiftDown()) {
            selectNextMenuItem(-1);
        } else {
            selectNextMenuItem(+1);
        }
    }
}
 
Example 16
Source File: SwingUtils.java    From SmartIM with Apache License 2.0 5 votes vote down vote up
public static String key2string(KeyEvent e) {
    String key = "";
    if (e.getKeyCode() == KeyEvent.VK_ENTER) {
        key = "Enter";
    }
    if (e.isShiftDown()) {
        key = "Shit + " + key;
    }
    if (e.isControlDown()) {
        key = "Ctrl + " + key;
    }
    return key;
}
 
Example 17
Source File: CompletionResultItem.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public void processKeyEvent(KeyEvent e) {
    shift = (e.getKeyCode() == KeyEvent.VK_ENTER &&
             e.getID() == KeyEvent.KEY_PRESSED && e.isShiftDown());
}
 
Example 18
Source File: DiskLayoutSelection.java    From DiskBrowser with GNU General Public License v3.0 4 votes vote down vote up
void cursorMove (FormattedDisk formattedDisk, KeyEvent e)
// ---------------------------------------------------------------------------------//
{
  if (highlights.size () == 0)
  {
    System.out.println ("Nothing to move");
    return;
  }

  Disk disk = formattedDisk.getDisk ();

  DiskAddress first = highlights.get (0);
  DiskAddress last = highlights.get (highlights.size () - 1);

  if (!e.isShiftDown ())
    highlights.clear ();

  int totalBlocks = disk.getTotalBlocks ();
  //    int rowSize = disk.getTrackSize () / disk.getBlockSize ();
  Dimension gridLayout = formattedDisk.getGridLayout ();
  int rowSize = gridLayout.width;

  switch (e.getKeyCode ())
  {
    case KeyEvent.VK_LEFT:
      int block = first.getBlockNo () - 1;
      if (block < 0)
        block = totalBlocks - 1;
      addHighlight (disk.getDiskAddress (block));
      break;

    case KeyEvent.VK_RIGHT:
      block = last.getBlockNo () + 1;
      if (block >= totalBlocks)
        block = 0;
      addHighlight (disk.getDiskAddress (block));
      break;

    case KeyEvent.VK_UP:
      block = first.getBlockNo () - rowSize;
      if (block < 0)
        block += totalBlocks;
      addHighlight (disk.getDiskAddress (block));
      break;

    case KeyEvent.VK_DOWN:
      block = last.getBlockNo () + rowSize;
      if (block >= totalBlocks)
        block -= totalBlocks;
      addHighlight (disk.getDiskAddress (block));
      break;
  }
  Collections.sort (highlights);
}
 
Example 19
Source File: AbstractRenderComponent.java    From pentaho-reporting with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void keyPressed( final KeyEvent keyEvent ) {
  // move all selected components 1px
  List<Element> selectedElements =
    getRenderContext().getSelectionModel().getSelectedElementsOfType( Element.class );
  if ( selectedElements.isEmpty() ) {
    return;
  }

  // if any element's X or Y is == 0, then do not move anything
  // PRD-1442
  final int keyCode = keyEvent.getKeyCode();
  if ( keyCode != KeyEvent.VK_UP && keyCode != KeyEvent.VK_DOWN &&
    keyCode != KeyEvent.VK_LEFT && keyCode != KeyEvent.VK_RIGHT ) {
    return;
  }

  if ( keyEvent.isShiftDown() || keyEvent.isAltDown() || keyEvent.isControlDown() ) {
    return;
  }

  keyEvent.consume();

  for ( final Element element : selectedElements ) {
    if ( element instanceof RootLevelBand ) {
      continue;
    }
    final double elementX = element.getStyle().getDoubleStyleProperty( ElementStyleKeys.POS_X, 0 );
    final double elementY = element.getStyle().getDoubleStyleProperty( ElementStyleKeys.POS_Y, 0 );
    // check if we can't move, one of the elements in the group is already at the minimum position
    if ( keyCode == KeyEvent.VK_UP && elementY == 0 ) {
      return;
    } else if ( keyCode == KeyEvent.VK_LEFT && elementX == 0 ) {
      return;
    }
  }

  final MassElementStyleUndoEntryBuilder builder = new MassElementStyleUndoEntryBuilder( selectedElements );
  final MoveDragOperation mop =
    new MoveDragOperation( selectedElements, new Point(), EmptySnapModel.INSTANCE, EmptySnapModel.INSTANCE );

  if ( keyCode == KeyEvent.VK_UP ) {
    mop.update( new Point( 0, -1 ), 1 );
  } else if ( keyCode == KeyEvent.VK_DOWN ) {
    mop.update( new Point( 0, 1 ), 1 );
  } else if ( keyCode == KeyEvent.VK_LEFT ) {
    mop.update( new Point( -1, 0 ), 1 );
  } else {
    mop.update( new Point( 1, 0 ), 1 );
  }
  final MassElementStyleUndoEntry massElementStyleUndoEntry = builder.finish();
  getRenderContext().getUndo()
    .addChange( Messages.getString( "AbstractRenderComponent.MoveUndoName" ), massElementStyleUndoEntry );
  mop.finish();
}
 
Example 20
Source File: ChartPanelShiftController.java    From rapidminer-studio with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * Pan / Shifts a plot if the arrow keys are pressed.
 */
public void keyPressed(KeyEvent e) {
	if (!plotSupported) {
		return;
	}

	int keyCode = e.getKeyCode();

	// we're only interested in arrows (code 37,38,39,40)
	if ((keyCode < 37) || (keyCode > 40)) {
		return;
	}

	// The axes we're gonna shift
	ValueAxis[] axes = null;

	boolean domainShift = false; // used for PAN_FIXED
	// Calculations for the domain axis
	if ((keyCode == KeyEvent.VK_LEFT) || (keyCode == KeyEvent.VK_RIGHT)) {
		axes = getPlotAxis(chartPanel.getChart(), !axesSwaped);
		domainShift = true;
	}
	// Calculations for the range axis
	else {
		axes = getPlotAxis(chartPanel.getChart(), axesSwaped);
	}

	// Delta is the amount we'll shift in axes units.
	double[] delta = new double[axes.length];

	// Let's calculate 'delta', the amount by which we'll shift the plot
	for (int i = 0; i < axes.length; i++) {
		switch (shiftType) {
			case SHIFT_PERCENTUAL:
				delta[i] = (axes[i].getUpperBound() - axes[i].getLowerBound()) / 100.0;
				break;
			case SHIFT_FIXED:
				delta[i] = (domainShift ? fixedDomainShiftUnits : fixedRangeShiftUnits);
				break;
			case SHIFT_PIXEL: // also the default
			default:
				// Let's find out what's the range for 1 pixel.
				final Rectangle2D scaledDataArea = chartPanel.getScreenDataArea();
				delta[i] = axes[i].getRange().getLength() / (scaledDataArea.getWidth());
				break;
		}
	}

	// Shift modifier multiplies delta by 10
	if (e.isShiftDown()) {
		for (int i = 0; i < delta.length; i++) {
			delta[i] *= 10;
		}
	}

	for (int i = 0; i < axes.length; i++) {
		switch (keyCode) {
			case KeyEvent.VK_LEFT:
			case KeyEvent.VK_DOWN:
				axes[i].setRange(axes[i].getLowerBound() - delta[i], axes[i].getUpperBound() - delta[i]);
				break;
			case KeyEvent.VK_UP:
			case KeyEvent.VK_RIGHT:
				axes[i].setRange(axes[i].getLowerBound() + delta[i], axes[i].getUpperBound() + delta[i]);
				break;
		}
	}
}