List of usage examples for java.awt.event KeyEvent VK_DOWN
int VK_DOWN
To view the source code for java.awt.event KeyEvent VK_DOWN.
Click Source Link
From source file:com.fanniemae.ezpie.actions.HighlightScan.java
private void changeOracleExtractExtension(File castExtractionFile) { ProcessBuilder pb = new ProcessBuilder("java", "-jar", _dbDeliveryToolPath); Process process = null;//from w ww. j av a 2 s . com Robot robot = null; try { process = pb.start(); robot = new Robot(); } catch (IOException | AWTException e) { throw new PieException("Could not start Oracle extract.", e); } sleep(15000); // navigating to input text for (int i = 0; i < 3; i++) { keyPressRelease(KeyEvent.VK_TAB, 200); sleep(200); } // select populated target folder path keyPressReleaseControlA(500); // entering target folder path Keyboard keyboard = new Keyboard(robot); keyboard.type(castExtractionFile.getParent() + "\\deliveryResults"); // navigate to options keyPressReleaseShiftTab(200); keyPressRelease(KeyEvent.VK_RIGHT, 500); for (int i = 0; i < 2; i++) { keyPressRelease(KeyEvent.VK_TAB, 200); sleep(200); } // select populated extraction file path keyPressReleaseControlA(500); // entering target folder path that contains .castextraction file keyboard.type(castExtractionFile.getPath()); sleep(500); keyPressRelease(KeyEvent.VK_TAB, 200); sleep(500); // navigate to menu bar to select Application/Run Application since tabbing to 'Run Application' button // and pressing enter does not execute run keyPressRelease(KeyEvent.VK_ALT, 500); sleep(500); for (int i = 0; i < 2; i++) { keyPressRelease(KeyEvent.VK_RIGHT, 200); } keyPressRelease(KeyEvent.VK_ENTER, 200); keyPressRelease(KeyEvent.VK_DOWN, 500); keyPressRelease(KeyEvent.VK_ENTER, 200); sleep(5000); process.destroy(); }
From source file:cz.babi.desktop.remoteme.common.Controller.java
/** * Make key stroke.//from ww w . j a v a 2 s .com * @param character Key(s) to stroke. */ private void makeStroke(Integer[] keyCodes) { /* * There is a bug with shift and arrows. * Workaround is turn num lock off. * http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4908075 */ boolean needSetNumlockOn = false; /* If numlock is on. */ if (Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_NUM_LOCK)) { boolean isShift = false; boolean isArrow = false; /* Check if there is a shift or an arrow. */ for (Integer integer : keyCodes) { if (integer == KeyEvent.VK_SHIFT) isShift = true; if (integer == KeyEvent.VK_LEFT) isArrow = true; if (integer == KeyEvent.VK_RIGHT) isArrow = true; if (integer == KeyEvent.VK_UP) isArrow = true; if (integer == KeyEvent.VK_DOWN) isArrow = true; } /* Disable numlock. */ if (isShift && isArrow) { robot.keyPress(KeyEvent.VK_NUM_LOCK); robot.keyRelease(KeyEvent.VK_NUM_LOCK); needSetNumlockOn = true; } } /* Do press. */ for (int i = 0; i < keyCodes.length; i++) { if (Common.DEBUG) LOGGER.debug("[keyPress][" + keyCodes[i] + "]"); robot.keyPress(keyCodes[i]); } /* Do release. */ for (int i = keyCodes.length - 1; i >= 0; i--) { if (Common.DEBUG) LOGGER.debug("[keyRelease][" + keyCodes[i] + "]"); robot.keyRelease(keyCodes[i]); } /* Set numlock back. */ if (needSetNumlockOn) { robot.keyPress(KeyEvent.VK_NUM_LOCK); robot.keyRelease(KeyEvent.VK_NUM_LOCK); } }
From source file:CopyAreaPerformance.java
/** * Arrow keys scroll the view around. The 'c' key toggles clip area * optimization. The 'a' key toggles copyArea optimization. */// w w w. jav a 2 s .c o m public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_RIGHT) { scroll(SCROLL_SIZE, 0); } else if (e.getKeyCode() == KeyEvent.VK_LEFT) { scroll(-SCROLL_SIZE, 0); } else if (e.getKeyCode() == KeyEvent.VK_UP) { scroll(0, -SCROLL_SIZE); } else if (e.getKeyCode() == KeyEvent.VK_DOWN) { scroll(0, SCROLL_SIZE); } else if (e.getKeyCode() == KeyEvent.VK_C) { useClip = !useClip; System.out.println("useClip = " + useClip); } else if (e.getKeyCode() == KeyEvent.VK_A) { useCopyArea = !useCopyArea; prevVX = -10000; System.out.println("useCopyArea = " + useCopyArea); } }
From source file:org.tmpotter.ui.ActionHandler.java
public void onTablePressed(final KeyEvent event) { int index;//from w ww. j a v a 2 s . c o m if (modelMediator.getTmViewSelectedRow() != -1) { index = modelMediator.getTmViewSelectedRow(); tmData.setPositionTextArea(0); } else { index = 1; } if (index < modelMediator.getTmViewRows() - 1) { if ((event.getKeyCode() == KeyEvent.VK_DOWN) || (event.getKeyCode() == KeyEvent.VK_NUMPAD2)) { if (tmData.getIndexPrevious() < tmData.getDocumentOriginalSize()) { tmData.setOriginalDocumentAnt(restoreText(modelMediator.getLeftEdit())); tmData.setTranslationDocumentAnt(restoreText(modelMediator.getRightEdit())); } modelMediator.setLeftEdit(formatText(modelMediator.getLeftSegment(index + 1))); modelMediator.setRightEdit(formatText(modelMediator.getRightSegment(index + 1))); tmData.setIndexCurrent(index + 1); } else if ((event.getKeyCode() == KeyEvent.VK_UP) || (event.getKeyCode() == KeyEvent.VK_NUMPAD8)) { tmData.setIndexCurrent(index - 1); if (index == 0) { index = 1; tmData.setIndexCurrent(0); } if (tmData.getIndexPrevious() < tmData.getDocumentOriginalSize()) { tmData.setOriginalDocumentAnt(restoreText(modelMediator.getLeftEdit())); tmData.setTranslationDocumentAnt(restoreText(modelMediator.getRightEdit())); } modelMediator.setLeftEdit(formatText(modelMediator.getLeftSegment(index - 1))); modelMediator.setRightEdit(formatText(modelMediator.getRightSegment(index - 1))); } if (tmData.isIdentTop()) { modelMediator.setJoinEnabled(false); } else { modelMediator.setJoinEnabled(true); } tmData.setIndexPrevious(tmData.getIndexCurrent()); } modelMediator.updateTmView(); }
From source file:net.rptools.tokentool.ui.TokenCompositionPanel.java
public void keyReleased(KeyEvent e) { switch (e.getKeyCode()) { case java.awt.event.KeyEvent.VK_UP: tokenOffsetY += -1;/*from w ww .j av a 2 s .c o m*/ repaint(); fireCompositionChanged(); break; case java.awt.event.KeyEvent.VK_DOWN: tokenOffsetY += 1; repaint(); fireCompositionChanged(); break; case java.awt.event.KeyEvent.VK_LEFT: tokenOffsetX += -1; repaint(); fireCompositionChanged(); break; case java.awt.event.KeyEvent.VK_RIGHT: tokenOffsetX += 1; repaint(); fireCompositionChanged(); } }
From source file:com.haulmont.cuba.desktop.gui.components.DesktopSuggestionField.java
public DesktopSuggestionField() { composition = new JPanel(); composition.setLayout(new BorderLayout()); composition.setFocusable(false);/*from w ww . j a va 2s.c o m*/ comboBox = new SearchComboBox() { @Override public void setPopupVisible(boolean v) { if (!items.isEmpty()) { super.setPopupVisible(v); } else if (!v) { super.setPopupVisible(false); } } @Override public void actionPerformed(ActionEvent e) { if (SearchAutoCompleteSupport.SEARCH_ENTER_COMMAND.equals(e.getActionCommand())) { enterHandling = true; } super.actionPerformed(e); } }; comboBox.addActionListener(e -> { if (settingValue || disableActionListener) { return; } if ("comboBoxEdited".equals(e.getActionCommand())) { Object selectedItem = comboBox.getSelectedItem(); if (popupItemSelectionHandling) { if (selectedItem instanceof ValueWrapper) { Object selectedValue = ((ValueWrapper) selectedItem).getValue(); setValue(selectedValue); } } else if (enterHandling) { if (selectedItem instanceof String) { boolean found = false; String newFilter = (String) selectedItem; if (prevValue != null) { if (Objects.equals(getDisplayString(prevValue), newFilter)) { found = true; } } final boolean searchStringEqualsToCurrentValue = found; // we need to do it later // unable to change current text from ActionListener SwingUtilities.invokeLater(() -> { updateComponent(prevValue); if (!searchStringEqualsToCurrentValue) { handleOnEnterAction(((String) selectedItem)); } }); } else if (currentSearchComponentText != null) { // Disable variants after select final String enterActionString = currentSearchComponentText; SwingUtilities.invokeLater(() -> { updateComponent(prevValue); handleOnEnterAction(enterActionString); }); currentSearchComponentText = null; } } clearSearchVariants(); popupItemSelectionHandling = false; enterHandling = false; } SwingUtilities.invokeLater(this::updateEditState); }); Component editorComponent = comboBox.getEditor().getEditorComponent(); editorComponent.addKeyListener(new KeyAdapter() { @Override public void keyTyped(KeyEvent e) { SwingUtilities.invokeLater(() -> { updateEditState(); if (e.getKeyChar() != '\n') { handleSearchInput(); } }); } @Override public void keyPressed(KeyEvent e) { SwingUtilities.invokeLater(() -> { if (e.getKeyCode() == KeyEvent.VK_DOWN && arrowDownActionHandler != null && !comboBox.isPopupVisible()) { arrowDownActionHandler.onArrowDownKeyPressed(getComboBoxEditorField().getText()); } }); } }); comboBox.setEditable(true); comboBox.setPrototypeDisplayValue("AAAAAAAAAAAA"); autoComplete = SearchAutoCompleteSupport.install(comboBox, items); autoComplete.setFilterEnabled(false); for (int i = 0; i < comboBox.getComponentCount(); i++) { Component component = comboBox.getComponent(i); component.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { clearSearchVariants(); // Reset invalid value checkSelectedValue(); } }); } final JTextField searchEditorComponent = getComboBoxEditorField(); searchEditorComponent.addActionListener(e -> currentSearchComponentText = searchEditorComponent.getText()); // set value only on PopupMenu closing to avoid firing listeners on keyboard navigation comboBox.addPopupMenuListener(new PopupMenuListener() { @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { comboBox.updatePopupWidth(); } @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { if (!autoComplete.isEditableState()) { popupItemSelectionHandling = comboBox.getSelectedIndex() >= 0; // Only if really item changed if (!enterHandling) { Object selectedItem = comboBox.getSelectedItem(); if (selectedItem instanceof ValueWrapper) { Object selectedValue = ((ValueWrapper) selectedItem).getValue(); setValue(selectedValue); clearSearchVariants(); } } updateMissingValueState(); } } @Override public void popupMenuCanceled(PopupMenuEvent e) { clearSearchVariants(); } }); textField = new JTextField(); textField.setEditable(false); UserSessionSource sessionSource = AppBeans.get(UserSessionSource.NAME); valueFormatter = new DefaultValueFormatter(sessionSource.getLocale()); composition.add(comboBox, BorderLayout.CENTER); impl = comboBox; DesktopComponentsHelper.adjustSize(comboBox); Configuration configuration = AppBeans.get(Configuration.NAME); asyncSearchDelayMs = configuration.getConfig(ClientConfig.class).getSuggestionFieldAsyncSearchDelayMs(); }
From source file:org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils.java
public static void scrollDown() throws AWTException { Robot robot = new Robot(); robot.keyPress(KeyEvent.VK_DOWN); robot.keyRelease(KeyEvent.VK_DOWN); }
From source file:bio.gcat.gui.BDATool.java
public BDATool() { super("BDA Tool - " + AnalysisTool.NAME); setIconImage(getImage("bda")); setMinimumSize(new Dimension(660, 400)); setPreferredSize(new Dimension(1020, 400)); setSize(getPreferredSize());//from w w w . j av a 2s. c om setLocationByPlatform(true); setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); menubar = new JMenuBar(); menu = new JMenu[4]; menubar.add(menu[0] = new JMenu("File")); menubar.add(menu[1] = new JMenu("Edit")); menubar.add(menu[2] = new JMenu("Window")); menubar.add(menu[3] = new JMenu("Help")); setJMenuBar(menubar); menu[0].add(createMenuItem("Open...", "folder-horizontal-open", KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_DOWN_MASK), ACTION_OPEN, this)); menu[0].add(createMenuItem("Save As...", "disk--arrow", KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK), ACTION_SAVE_AS, this)); menu[0].add(createSeparator()); menu[0].add(createMenuItem("Close Window", "cross", ACTION_CLOSE, this)); menu[1].add(createMenuText("Binary Dichotomic Algorithm:")); menu[1].add(createMenuItem("Add", KeyStroke.getKeyStroke(KeyEvent.VK_A, InputEvent.CTRL_DOWN_MASK), ACTION_BDA_ADD, this)); menu[1].add(createMenuItem("Edit...", KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.CTRL_DOWN_MASK), ACTION_BDA_EDIT, this)); menu[1].add( createMenuItem("Remove", KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), ACTION_BDA_REMOVE, this)); menu[1].add(createMenuItem("Clear", ACTION_BDAS_CLEAR, this)); menu[1].add(seperateMenuItem(createMenuItem("Move Up", KeyStroke.getKeyStroke(KeyEvent.VK_UP, InputEvent.CTRL_DOWN_MASK), ACTION_BDA_MOVE_UP, this))); menu[1].add(createMenuItem("Move Down", KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, InputEvent.CTRL_DOWN_MASK), ACTION_BDA_MOVE_DOWN, this)); menu[2].add(createMenuItem("Preferences", ACTION_PREFERENCES, this)); menu[3].add(createMenuItem("About BDA Tool", "bda", ACTION_ABOUT, this)); for (String action : new String[] { ACTION_BDA_EDIT, ACTION_BDA_REMOVE, ACTION_BDAS_CLEAR, ACTION_BDA_MOVE_UP, ACTION_BDA_MOVE_DOWN }) getMenuItem(menubar, action).setEnabled(false); getMenuItem(menubar, ACTION_PREFERENCES).setEnabled(false); registerKeyStroke(getRootPane(), KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "remove", new ActionListener() { @Override public void actionPerformed(ActionEvent event) { if (bdaPanel.table.hasFocus()) removeBinaryDichotomicAlgorithm(); } }); toolbar = new JToolBar[1]; toolbar[0] = new JToolBar("File"); toolbar[0].add(createToolbarButton("Open File", "folder-horizontal-open", ACTION_OPEN, this)); toolbar[0].add(createToolbarButton("Save As File", "disk--arrow", ACTION_SAVE_AS, this)); toolbars = new JPanel(new FlowLayout(FlowLayout.LEADING)); for (JToolBar toolbar : toolbar) toolbars.add(toolbar); add(toolbars, BorderLayout.NORTH); add(createSplitPane(JSplitPane.HORIZONTAL_SPLIT, false, true, 360, 0.195, new JScrollPane(bdaPanel = new BinaryDichotomicAlgorithmPanel()), new JScrollPane(tablePanel = new JPanel(new BorderLayout()))), BorderLayout.CENTER); add(bottom = new JPanel(new FlowLayout(FlowLayout.RIGHT)), BorderLayout.SOUTH); status = new JLabel(); status.setBorder(new EmptyBorder(0, 5, 0, 5)); status.setHorizontalAlignment(JLabel.RIGHT); bottom.add(status); ((ListTableModel<?>) bdaPanel.table.getModel()).addListDataListener(this); bdaPanel.table.getSelectionModel().addListSelectionListener(this); revalidateGeneticCodeTable(); }
From source file:adams.gui.tools.TelnetPanel.java
/** * For initializing the GUI./*w w w.j av a 2 s. c o m*/ */ @Override protected void initGUI() { JPanel topPanel; JPanel bottomPanel; JLabel label; super.initGUI(); setLayout(new BorderLayout()); // connection topPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); add(topPanel, BorderLayout.NORTH); m_TextRemote = new BaseTextField(20); label = new JLabel("Remote"); label.setDisplayedMnemonic('R'); label.setLabelFor(m_TextRemote); topPanel.add(label); topPanel.add(m_TextRemote); m_PortModel = new SpinnerNumberModel(); m_PortModel.setMinimum(1); m_PortModel.setMaximum(65536); m_PortModel.setStepSize(1); m_PortModel.setValue(23); m_SpinnerPort = new JSpinner(m_PortModel); label = new JLabel("Port"); label.setDisplayedMnemonic('P'); label.setLabelFor(m_SpinnerPort); topPanel.add(label); topPanel.add(m_SpinnerPort); m_ButtonConnection = new BaseButton(); m_ButtonConnection.setMnemonic('n'); m_ButtonConnection.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { handleConnectionEvent(); } }); topPanel.add(m_ButtonConnection); // output m_ButtonClear = new BaseButton("Clear", GUIHelper.getIcon("new.gif")); m_ButtonClear.setMnemonic('l'); m_ButtonClear.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { m_TextOutput.setText(""); } }); m_ButtonCopy = new BaseButton("Copy", GUIHelper.getIcon("copy.gif")); m_ButtonCopy.setMnemonic('C'); m_ButtonCopy.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (m_TextOutput.getSelectedText().length() > 0) ClipboardHelper.copyToClipboard(m_TextOutput.getSelectedText()); else if (m_TextOutput.getText().length() > 0) ClipboardHelper.copyToClipboard(m_TextOutput.getText()); } }); m_TextOutput = new BaseTextAreaWithButtons(10, 40); m_TextOutput.setTextFont(Fonts.getMonospacedFont()); m_TextOutput.addToButtonsPanel(m_ButtonClear); m_TextOutput.addToButtonsPanel(m_ButtonCopy); add(m_TextOutput, BorderLayout.CENTER); // commands bottomPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); add(bottomPanel, BorderLayout.SOUTH); m_TextCommand = new BaseTextField(40); m_TextCommand.setFont(Fonts.getMonospacedFont()); m_TextCommand.addKeyListener(new KeyListener() { @Override public void keyTyped(KeyEvent e) { } @Override public void keyReleased(KeyEvent e) { } @Override public void keyPressed(KeyEvent e) { switch (e.getKeyCode()) { case KeyEvent.VK_ENTER: e.consume(); execCommand(); break; case KeyEvent.VK_UP: e.consume(); previousCommand(); break; case KeyEvent.VK_DOWN: e.consume(); nextCommand(); break; } } }); label = new JLabel("Command"); label.setDisplayedMnemonic('m'); label.setLabelFor(m_TextCommand); bottomPanel.add(label); bottomPanel.add(m_TextCommand); m_ButtonCommand = new BaseButton(GUIHelper.getIcon("run.gif")); m_ButtonCommand.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { execCommand(); } }); bottomPanel.add(m_ButtonCommand); }
From source file:com.rapidminer.gui.plotter.charts.ChartPanelShiftController.java
/** * Pan / Shifts a plot if the arrow keys are pressed. *//* w w w. ja v a2 s . c om*/ 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; } } }