Example usage for java.awt.event KeyEvent VK_SPACE

List of usage examples for java.awt.event KeyEvent VK_SPACE

Introduction

In this page you can find the example usage for java.awt.event KeyEvent VK_SPACE.

Prototype

int VK_SPACE

To view the source code for java.awt.event KeyEvent VK_SPACE.

Click Source Link

Document

Constant for the SPACE virtual key.

Usage

From source file:com.photon.phresco.Screens.InvalidJarBase.java

public void instantiateBrowser(String selectedBrowser, String selectedPlatform, String applicationURL,
        String applicationContext) throws ScreenException, MalformedURLException {

    if (selectedBrowser.equalsIgnoreCase(Constants.BROWSER_CHROME)) {
        try {//from   www . ja  v  a2  s . c  o  m
            // "D:/Selenium-jar/chromedriver_win_19.0.1068.0/chromedriver.exe"
            chromeService = new ChromeDriverService.Builder()
                    .usingDriverExecutable(new File(getChromeLocation())).usingAnyFreePort().build();

            log.info("-------------***LAUNCHING GOOGLECHROME***--------------");

            driver = new ChromeDriver(chromeService);
            //driver.manage().window().maximize();
            //   driver = new ChromeDriver(chromeService, chromeOption);
            // driver.manage().timeouts().implicitlyWait(30,
            // TimeUnit.SECONDS);            
            //driver.navigate().to(applicationURL + applicationContext);
            driver.manage().window().maximize();
            driver.navigate().to(applicationURL + applicationContext);

        } catch (Exception e) {
            e.printStackTrace();
        }

    } else if (selectedBrowser.equalsIgnoreCase(Constants.BROWSER_IE)) {
        log.info("---------------***LAUNCHING INTERNET EXPLORE***-----------");
        driver = new InternetExplorerDriver();
        driver.manage().window().maximize();
        driver.navigate().to(applicationURL + applicationContext);

    } else if (selectedBrowser.equalsIgnoreCase(Constants.BROWSER_FIREFOX)) {
        log.info("-------------***LAUNCHING FIREFOX***--------------");
        driver = new FirefoxDriver();
        driver.manage().window().maximize();
        driver.navigate().to(applicationURL + applicationContext);

    } else if (selectedBrowser.equalsIgnoreCase(Constants.BROWSER_OPERA)) {
        log.info("-------------***LAUNCHING OPERA***--------------");
        System.out.println("******entering window maximize********");
        try {
            System.out.println("******entering window maximize********");
            Robot robot;
            try {
                robot = new Robot();
                robot.keyPress(KeyEvent.VK_ALT);
                robot.keyPress(KeyEvent.VK_SPACE);
                robot.keyRelease(KeyEvent.VK_ALT);
                robot.keyRelease(KeyEvent.VK_SPACE);
                robot.keyPress(KeyEvent.VK_X);
                robot.keyRelease(KeyEvent.VK_X);
            } catch (AWTException e) {

                e.printStackTrace();
            }

        } catch (Exception e) {

            e.printStackTrace();
        }

    } else {
        throw new ScreenException("------Only FireFox,InternetExplore and Chrome works-----------");
    }

}

From source file:ru.goodfil.catalog.ui.forms.OePanel.java

private void lstOesKeyPressed(KeyEvent e) {
    if (e != null) {
        if (e.getKeyCode() == KeyEvent.VK_INSERT) {
            btnCreateOeActionPerformed(null);
        }/*from   ww  w .j  a v a 2s  .com*/
        if (e.getKeyCode() == KeyEvent.VK_DELETE) {
            btnRemoveOeActionPerformed(null);
        }
        if (e.getKeyCode() == KeyEvent.VK_SPACE) {
            btnEditOeActionPerformed(null);
        }
        if ((e.getKeyCode() == KeyEvent.VK_X) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) {
            List<Oe> selectedOes = oes.getSelectedItems();
            putObjectToMyClipboard(selectedOes);
            this.setOperation(OPERATION_CUT);
        }
        if ((e.getKeyCode() == KeyEvent.VK_C) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) {
            List<Oe> selectedOes = oes.getSelectedItems();
            putObjectToMyClipboard(selectedOes);
            this.setOperation(OPERATION_COPY);
        }
        if ((e.getKeyCode() == KeyEvent.VK_V) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) {
            if (popupMenu1.getInvoker() == lstOes) {
                List<Oe> selectedOes = new ArrayList();
                selectedOes.addAll(getFromClipboardByType(Oe.class));
                if (selectedOes.size() > 0) {
                    Long brand = brands.getSelectedItemId();
                    Assert.notNull(brand);
                    if (getOperation() == OPERATION_COPY) {
                        analogsService.doCopyOe(selectedOes, brand);
                    }
                    if (getOperation() == OPERATION_CUT) {
                        analogsService.doCutOe(selectedOes, brand);
                    }
                    reReadOes(brand);
                }
            }
        }
    }
}

From source file:org.kalypso.kalypsomodel1d2d.ui.map.RefineFEGeometryWidget.java

@Override
public void keyPressed(final KeyEvent e) {
    if (e.getKeyCode() == KeyEvent.VK_SPACE) {
        m_modePolygon = !m_modePolygon;/*from   ww w .java2s  . c om*/
        reinit();
    } else if (e.getKeyCode() == KeyEvent.VK_ESCAPE)
        reinit();
    else if (e.getKeyCode() == KeyEvent.VK_BACK_SPACE)
        m_geometryBuilder.removeLastPoint();
    else if (e.getKeyCode() == KeyEvent.VK_ENTER)
        convertRefinementToModel();
    else
        super.keyPressed(e);
}

From source file:view.QuestionLab.java

/**
 * Creates new form QuestionLab/*from w  ww  . j a v a2 s . com*/
 */
public QuestionLab(java.awt.Frame parent, boolean modal) {
    super(parent, modal);
    try {

        initComponents();
        submitButton.setVisible(false);
        jCheckBox1.setEnabled(false);
        jCheckBox3.setEnabled(false);
        jCheckBox4.setEnabled(false);
        jCheckBox5.setEnabled(false);
        jCheckBox7.setEnabled(false);
        jCheckBox8.setEnabled(false);
        jCheckBox9.setEnabled(false);
        jCheckBox10.setEnabled(false);
        submitButton.setEnabled(false);
        backButton.setEnabled(false);

        controller = ServerConnector.getServerConnector().getStudentController();
        studentObserverImpl = new StudentObserverImpl(this);
        controller.addObserve(studentObserverImpl);
        //controller.onlineNow();
        //displayMessage(Integer.toString(onlineNow));
        muteButton.setEnabled(false);
        setSize(Toolkit.getDefaultToolkit().getScreenSize());
        UIManager.setLookAndFeel(new GraphiteLookAndFeel());

        DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
        date = new Date();
        System.out.println(dateFormat.format(date));
        newDate = dateFormat.format(date);
        JButton buttonArrayListOne[][] = { { jButton1, jButton2, jButton3, jButton4, jButton5 },
                { jButton6, jButton7, jButton8, jButton9, jButton10 },
                { jButton11, jButton12, jButton13, jButton14, jButton15 },
                { jButton16, jButton17, jButton18, jButton19, jButton20 },
                { jButton21, jButton22, jButton23, jButton24, jButton25 },
                { jButton26, jButton27, jButton28, jButton29, jButton30 },
                { jButton31, jButton32, jButton33, jButton34, jButton35 },
                { jButton36, jButton37, jButton38, jButton39, jButton40 },
                { jButton41, jButton42, jButton43, jButton44, jButton45 },
                { jButton46, jButton47, jButton48, jButton49, jButton50 },
                { jButton51, jButton52, jButton53, jButton54, jButton55 },
                { jButton56, jButton57, jButton58, jButton59, jButton60 }

        };

        this.buttonArrayList = buttonArrayListOne;
        System.out.println("MyNIc" + PracticeExamLogIn.studentNic);
        new Timer(1000, new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                int hour = secondsLeft / 3600;
                int min = secondsLeft / 60 - hour * 60;
                int second = secondsLeft % 60;

                if (hour == 0) {
                    int seconds = secondsLeft % 60;

                    jLabel7.setText(Integer.toString(seconds));

                    jLabel8.setText("Minutes");
                    //   jLabel5.setText("Seconds");
                    jLabel6.setText(Integer.toString(min));

                } else {
                    jLabel6.setText(Integer.toString(hour));
                    jLabel7.setText(Integer.toString(min));
                    jLabel8.setText(Integer.toString(second));

                }
                secondsLeft--;
                if ("0".equals(jLabel6.getText()) && "0".equals(jLabel7.getText())) {
                    //check(); 
                    System.out.println("true");
                }

            }
        }).start();

        submitTextField.addKeyListener(new KeyAdapter() {
            public void keyTyped(KeyEvent e) {
                char c = e.getKeyChar();
                if (!((c >= 'a') && (c <= 'g') || (c == KeyEvent.VK_SPACE) || (c == KeyEvent.VK_TAB)
                        || (c == KeyEvent.VK_SPACE))) {
                    getToolkit().beep();
                    e.consume();
                }
            }
        });

        try {

            try {
                Exam exam = new Exam(PracticeExamLogIn.studentNic, date, anxCount);
                //    ExamController examController = ServerConnector.getServerConnector().getExamController();
                try {
                    boolean addMarks = ServerConnector.getServerConnector().getExamController().addMarks(exam);
                    // Exam exam = examController.addMarks(PracticeExamLogIn.studentNic, newDate, anxCount);
                    // if (addMarks) {
                    //   JOptionPane.showMessageDialog(QuestionLab.this, "Student Registered successfully !!");
                    //   this.dispose();
                    //    new LogIn(null, true).setVisible(true);

                    //                    } else {
                    //                        JOptionPane.showMessageDialog(QuestionLab.this, "Student Registered failed !!");
                    //                    }
                } catch (ClassNotFoundException | SQLException ex) {
                    Logger.getLogger(QuestionLab.class.getName()).log(Level.SEVERE, null, ex);
                }
            } catch (NotBoundException | MalformedURLException ex) {
                Logger.getLogger(QuestionLab.class.getName()).log(Level.SEVERE, null, ex);
            }

        } catch (RemoteException ex) {
            Logger.getLogger(QuestionLab.class.getName()).log(Level.SEVERE, null, ex);
        }

    } catch (UnsupportedLookAndFeelException ex) {
        Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
    } catch (NotBoundException | MalformedURLException | RemoteException ex) {
        Logger.getLogger(QuestionLab.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:com.all.browser.impl.MozillaBrowser.java

private void registerListeners() {
    mozillaPanel.addHierarchyBoundsListener(new HierarchyBoundsAdapter() {
        @Override/*  w ww  .j  ava2  s .  co  m*/
        public void ancestorResized(HierarchyEvent e) {
            Container changedParent = e.getChangedParent();
            if (changedParent != null) {
                mozillaPanel.setBounds(changedParent.getBounds());
            }
        }
    });

    mozillaPanel.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent e) {
            int keyCode = e.getKeyCode();
            if (keyCode == KeyEvent.VK_SPACE) {
                e.consume();
            }
        }
    });
}

From source file:com.varaneckas.hawkscope.cfg.Configuration.java

/**
 * Parses hotkey string and returns char value of the shortcut key
 *  //ww w  . j av a  2 s.  c  o m
 * @return int (char) of ascii key ranged from 32 to 126
 */
public int getHotkey() {
    final String hotkey = properties.get(HOTKEY_REPR);
    if (hotkey != null && hotkey.contains("+")) {
        //good hotkey
        if (hotkey.endsWith("Space")) {
            return KeyEvent.VK_SPACE;
        } else {
            return hotkey.charAt(hotkey.length() - 1);
        }
    }
    //bad or no hotkey
    return -1;
}

From source file:org.slage.tests.ImageTest.java

/** Hard-code a pause key click */
public void makePauseHandler() {
    addKeyHandler(new PauseHandler(this), KeyEvent.VK_F10);
    addKeyHandler(new QuitHandler(), KeyEvent.VK_Q, false, true, false);

    // toggle debug mode (bounding shapes, etc)
    addKeyHandler(new ToggleDebugHandler(this), KeyEvent.VK_TAB);

    // cycle toolbar rendering
    addKeyHandler(new CycleRenderHandler(this), KeyEvent.VK_EQUALS);

    addKeyHandler(new FocusConsoleHandler(this), KeyEvent.VK_ENTER);

    // manual scrolling
    addKeyHandler(new ScrollHandler(this, 5, 0), KeyEvent.VK_PAGE_UP);
    addKeyHandler(new ScrollHandler(this, -5, 0), KeyEvent.VK_PAGE_DOWN);

    // toggle scroll lock
    addKeyHandler(new LockViewportHandler(this, tryTheSpecial), java.awt.event.KeyEvent.VK_HOME);
    addKeyHandler(new LockViewportHandler(this), java.awt.event.KeyEvent.VK_END);

    addKeyHandler(new PrintHistory(this), java.awt.event.KeyEvent.VK_F1);

    // open imagetest in the editor
    addKeyHandler(new LaunchEditorHandler(this), java.awt.event.KeyEvent.VK_SCROLL_LOCK);

    // play a sound when space is pressed
    addKeyHandler(//from w  ww .  j  av a2  s.co m
            new PlaySoundHandler(this, Tools.GetFile("org.slage.tests.content", "congratulations-escaped.ogg")),
            java.awt.event.KeyEvent.VK_SPACE);

    // save the game
    addKeyHandler(new SaveWithChooserDialog(this), java.awt.event.KeyEvent.VK_F5);

    // inventory dialog, we hope
    addKeyHandler(new ShowInventoryHandler(getPlayer()), java.awt.event.KeyEvent.VK_F4);
    addKeyHandler(new CloseInventoryHandler(getPlayer()), java.awt.event.KeyEvent.VK_ESCAPE);

}

From source file:ome.formats.importer.gui.GuiCommonElements.java

/**
 * Fires a button click when using the enter key
 * //from   ww w. j a  v a2  s .co m
 * @param button to press when enter is pressed
 */
public static void enterPressesWhenFocused(JButton button) {

    button.registerKeyboardAction(
            button.getActionForKeyStroke(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0, false)),
            KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, false), JComponent.WHEN_FOCUSED);

    button.registerKeyboardAction(
            button.getActionForKeyStroke(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0, true)),
            KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, true), JComponent.WHEN_FOCUSED);

}

From source file:vistas.ModPersonal.java

private void txt_apellidoMKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txt_apellidoMKeyTyped
    char car = evt.getKeyChar();
    if ((car < 'a' || car > 'z') && (car < 'A' || car > 'Z') && (car != (char) KeyEvent.VK_SPACE)
            && (car != (char) KeyEvent.VK_BACK_SPACE)) {
        JOptionPane.showMessageDialog(this, "Ingrese solo letras");
        evt.consume();/* www  . j av  a  2 s.  c o  m*/
    }
}

From source file:Utilities.java

private static boolean usableKeyOnMac(int key, int mask) {
    //All permutations fail for Q except ctrl
    if (key == KeyEvent.VK_Q) {
        return false;
    }/*from   ww  w. j  av a  2  s.  c  o  m*/

    boolean isMeta = ((mask & KeyEvent.META_MASK) != 0) || ((mask & KeyEvent.CTRL_DOWN_MASK) != 0);

    boolean isAlt = ((mask & KeyEvent.ALT_MASK) != 0) || ((mask & KeyEvent.ALT_DOWN_MASK) != 0);

    boolean isOnlyMeta = isMeta && ((mask & ~(KeyEvent.META_DOWN_MASK | KeyEvent.META_MASK)) == 0);

    //Mac OS consumes keys Command+ these keys - the app will never see
    //them, so CTRL should not be remapped for these
    if (isOnlyMeta) {
        return (key != KeyEvent.VK_H) && (key != KeyEvent.VK_SPACE) && (key != KeyEvent.VK_TAB);
    } else
        return !((key == KeyEvent.VK_D) && isMeta && isAlt);
}