Example usage for java.awt.event KeyEvent getKeyCode

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

Introduction

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

Prototype

public int getKeyCode() 

Source Link

Document

Returns the integer keyCode associated with the key in this event.

Usage

From source file:com.igormaznitsa.sciareto.ui.MainFrame.java

private void menuFullScreenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuFullScreenActionPerformed
    final Component currentComponent = this.tabPane.getSelectedComponent();
    if (!(currentComponent instanceof Container)) {
        LOGGER.warn("Detected attempt to full screen not a container : " + currentComponent);
        return;/*from   w ww.  j  a va  2  s  .c o  m*/
    }

    final GraphicsConfiguration gconfig = this.getGraphicsConfiguration();
    if (gconfig != null) {
        final GraphicsDevice device = gconfig.getDevice();
        if (device.isFullScreenSupported()) {
            if (device.getFullScreenWindow() == null) {
                final JLabel label = new JLabel("Opened in full screen");
                final int tabIndex = this.tabPane.getSelectedIndex();
                this.tabPane.setComponentAt(tabIndex, label);
                final JWindow window = new JWindow(Main.getApplicationFrame());
                window.setAlwaysOnTop(true);
                window.setContentPane((Container) currentComponent);

                endFullScreenIfActive();

                final KeyEventDispatcher fullScreenEscCatcher = new KeyEventDispatcher() {
                    @Override
                    public boolean dispatchKeyEvent(@Nonnull final KeyEvent e) {
                        if (e.getID() == KeyEvent.KEY_PRESSED && (e.getKeyCode() == KeyEvent.VK_ESCAPE
                                || e.getKeyCode() == KeyEvent.VK_F11)) {
                            endFullScreenIfActive();
                            return true;
                        }
                        return false;
                    }
                };

                if (this.taskToEndFullScreen.compareAndSet(null, new Runnable() {
                    @Override
                    public void run() {
                        try {
                            window.dispose();
                        } finally {
                            tabPane.setComponentAt(tabIndex, currentComponent);
                            device.setFullScreenWindow(null);
                            KeyboardFocusManager.getCurrentKeyboardFocusManager()
                                    .removeKeyEventDispatcher(fullScreenEscCatcher);
                        }
                    }
                })) {
                    try {
                        KeyboardFocusManager.getCurrentKeyboardFocusManager()
                                .addKeyEventDispatcher(fullScreenEscCatcher);
                        device.setFullScreenWindow(window);
                    } catch (Exception ex) {
                        LOGGER.error("Can't turn on full screen", ex);
                        endFullScreenIfActive();
                        KeyboardFocusManager.getCurrentKeyboardFocusManager()
                                .removeKeyEventDispatcher(fullScreenEscCatcher);
                    }
                } else {
                    LOGGER.error("Unexpected state, processor is not null!");
                }
            } else {
                LOGGER.warn("Attempt to full screen device which already in full screen!");
            }
        } else {
            LOGGER.warn("Device doesn's support full screen");
            DialogProviderManager.getInstance().getDialogProvider()
                    .msgWarn("The Device doesn't support full-screen mode!");
        }
    } else {
        LOGGER.warn("Can't find graphics config for the frame");
    }
}

From source file:org.genedb.jogra.plugins.TermRationaliser.java

/**
 * Return a new JFrame which is the main interface to the Rationaliser.
 *///from   ww w. java2 s. com
public JFrame getMainPanel() {

    /* JFRAME */
    frame.setTitle(WINDOW_TITLE);
    frame.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
    frame.setLayout(new BorderLayout());

    /* MENU */
    JMenuBar menuBar = new JMenuBar();

    JMenu actions_menu = new JMenu("Actions");
    JMenuItem actions_mitem_1 = new JMenuItem("Refresh lists");
    actions_mitem_1.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            initModels();
        }
    });
    actions_menu.add(actions_mitem_1);

    JMenu about_menu = new JMenu("About");
    JMenuItem about_mitem_1 = new JMenuItem("About");
    about_mitem_1.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            JOptionPane.showMessageDialog(null,
                    "Term Rationaliser \n" + "Wellcome Trust Sanger Institute, UK \n" + "2009",
                    "Term Rationaliser", JOptionPane.PLAIN_MESSAGE);
        }
    });
    about_menu.add(about_mitem_1);

    menuBar.add(about_menu);
    menuBar.add(actions_menu);
    frame.add(menuBar, BorderLayout.NORTH);

    /* MAIN BOX */
    Box center = Box.createHorizontalBox(); //A box that displays contents from left to right
    center.add(Box.createHorizontalStrut(5)); //Invisible fixed-width component

    /* FROM LIST AND PANEL */
    fromList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); //Allow multiple products to be selected 
    fromList.addKeyListener(new KeyListener() {
        @Override
        public void keyPressed(KeyEvent arg0) {
            if (arg0.getKeyCode() == KeyEvent.VK_RIGHT) {
                synchroniseLists(fromList, toList); //synchronise from left to right
            }
        }

        @Override
        public void keyReleased(KeyEvent arg0) {
        }

        @Override
        public void keyTyped(KeyEvent arg0) {
        }
    });

    Box fromPanel = this.createRationaliserPanel(FROM_LIST_NAME, fromList); //Box on left hand side
    fromPanel.add(Box.createVerticalStrut(55)); //Add some space
    center.add(fromPanel); //Add to main box
    center.add(Box.createHorizontalStrut(3)); //Add some space

    /* MIDDLE PANE */
    Box middlePane = Box.createVerticalBox();

    ClassLoader classLoader = this.getClass().getClassLoader(); //Needed to access the images later on
    ImageIcon leftButtonIcon = new ImageIcon(classLoader.getResource("left_arrow.gif"));
    ImageIcon rightButtonIcon = new ImageIcon(classLoader.getResource("right_arrow.gif"));

    leftButtonIcon = new ImageIcon(leftButtonIcon.getImage().getScaledInstance(20, 20, Image.SCALE_SMOOTH)); //TODO: Investigate simpler way to resize an icon!
    rightButtonIcon = new ImageIcon(rightButtonIcon.getImage().getScaledInstance(20, 20, Image.SCALE_SMOOTH)); //TODO: Investigate simpler way to resize an icon!

    JButton rightSynch = new JButton(rightButtonIcon);
    rightSynch.setToolTipText("Synchronise TO list. \n Shortcut: Right-arrow key");

    rightSynch.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            synchroniseLists(fromList, toList);
        }
    });

    JButton leftSynch = new JButton(leftButtonIcon);
    leftSynch.setToolTipText("Synchronise FROM list. \n Shortcut: Left-arrow key");

    leftSynch.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            synchroniseLists(toList, fromList);
        }
    });

    middlePane.add(rightSynch);
    middlePane.add(leftSynch);

    center.add(middlePane); //Add middle pane to main box
    center.add(Box.createHorizontalStrut(3));

    /* TO LIST AND PANEL */
    toList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); //Single product selection in TO list
    toList.addKeyListener(new KeyListener() {
        @Override
        public void keyPressed(KeyEvent arg0) {
            if (arg0.getKeyCode() == KeyEvent.VK_LEFT) {
                synchroniseLists(toList, fromList); //synchronise from right to left
            }
        }

        @Override
        public void keyReleased(KeyEvent arg0) {
        }

        @Override
        public void keyTyped(KeyEvent arg0) {
        }
    });

    Box toPanel = this.createRationaliserPanel(TO_LIST_NAME, toList);

    Box newTerm = Box.createVerticalBox();

    textField = new JTextArea(1, 1); //textfield to let the user edit the name of an existing term
    textField.setMaximumSize(new Dimension(Toolkit.getDefaultToolkit().getScreenSize().height, 10));

    textField.setForeground(Color.BLUE);
    JScrollPane jsp = new JScrollPane(textField); //scroll pane so that there is a horizontal scrollbar
    jsp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);

    newTerm.add(jsp);
    TitledBorder editBorder = BorderFactory.createTitledBorder("Edit term name");
    editBorder.setTitleColor(Color.DARK_GRAY);
    newTerm.setBorder(editBorder);
    toPanel.add(newTerm); //add textfield to panel

    center.add(toPanel); //add panel to main box
    center.add(Box.createHorizontalStrut(5));

    frame.add(center); //add the main panel to the frame

    initModels(); //load the lists with data

    /* BOTTOM HALF OF FRAME */
    Box main = Box.createVerticalBox();
    TitledBorder border = BorderFactory.createTitledBorder("Information");
    border.setTitleColor(Color.DARK_GRAY);

    /* INFORMATION BOX */
    Box info = Box.createVerticalBox();

    Box scope = Box.createHorizontalBox();
    scope.add(Box.createHorizontalStrut(5));
    scope.add(scopeLabel); //label showing the scope of the terms
    scope.add(Box.createHorizontalGlue());

    Box productCount = Box.createHorizontalBox();
    productCount.add(Box.createHorizontalStrut(5));
    productCount.add(productCountLabel); //display the label showing the number of terms
    productCount.add(Box.createHorizontalGlue());

    info.add(scope);
    info.add(productCount);
    info.setBorder(border);

    /* ACTION BUTTONS */
    Box actionButtons = Box.createHorizontalBox();
    actionButtons.add(Box.createHorizontalGlue());
    actionButtons.add(Box.createHorizontalStrut(10));

    JButton findFix = new JButton(new FindClosestMatchAction());
    actionButtons.add(findFix);
    actionButtons.add(Box.createHorizontalStrut(10));

    RationaliserAction ra = new RationaliserAction();
    // RationaliserAction2 ra2 = new RationaliserAction2();
    JButton go = new JButton(ra);
    actionButtons.add(go);
    actionButtons.add(Box.createHorizontalGlue());

    /* MORE INFORMATION TOGGLE */
    Box buttonBox = Box.createHorizontalBox();
    final JButton toggle = new JButton("Hide information <<");

    buttonBox.add(Box.createHorizontalStrut(5));
    buttonBox.add(toggle);
    buttonBox.add(Box.createHorizontalGlue());

    Box textBox = Box.createHorizontalBox();

    final JScrollPane scrollPane = new JScrollPane(information);
    scrollPane.setPreferredSize(new Dimension(frame.getWidth(), 100));
    scrollPane.setVisible(true);
    textBox.add(Box.createHorizontalStrut(5));
    textBox.add(scrollPane);

    ActionListener actionListener = new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            if (toggle.getText().equals("Show information >>")) {
                scrollPane.setVisible(true);
                toggle.setText("Hide information <<");
                frame.setPreferredSize(new Dimension(frame.getWidth(), frame.getHeight() + 100));
                frame.pack();
            } else if (toggle.getText().equals("Hide information <<")) {
                scrollPane.setVisible(false);
                toggle.setText("Show information >>");
                frame.setPreferredSize(new Dimension(frame.getWidth(), frame.getHeight() - 100));
                frame.pack();
            }
        }
    };
    toggle.addActionListener(actionListener);

    main.add(Box.createVerticalStrut(5));
    main.add(info);
    main.add(Box.createVerticalStrut(5));
    main.add(Box.createVerticalStrut(5));
    main.add(actionButtons);
    main.add(Box.createVerticalStrut(10));
    main.add(buttonBox);
    main.add(textBox);

    frame.add(main, BorderLayout.SOUTH);
    frame.pack();
    frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    frame.setVisible(true);
    //initModels();

    return frame;
}

From source file:ch.zhaw.iamp.rct.ui.GrammarWindow.java

private void grammarTextPaneKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_grammarTextPaneKeyReleased
    if (evt != null && isArrowKeyCode(evt.getKeyCode())) {
        return;//from   ww w.j  av a  2  s .c o m
    }

    try {
        grammarParser.parse(grammarTextPane.getText());
    } catch (Exception ex) {
        System.out.println("Caught exception during parsing: " + ex.getMessage());
        return;
    }

    grammarTextPane.getHighlighter().removeAllHighlights();

    if (grammarParser.hasErrors()) {
        for (ParserError error : grammarParser.getErrors()) {
            highlightErrorLine(error.getLineIndex(), grammarTextPane);
        }
    } else {
        graphPanel.setNetworkGraph(grammarParser.getGraph());
        graphPanel.repaint();
    }

    initialisationTextPaneKeyReleased(null);
}

From source file:net.sf.maltcms.chromaui.chromatogram1Dviewer.ui.panel.Chromatogram1DHeatmapViewerPanel.java

@Override
public void keyPressed(KeyEvent ke) {
    Logger.getLogger(getClass().getName()).log(Level.INFO, "Received key event: {0}", ke.toString());
    if (ke.isControlDown()) {
        modeSpinner.setValue(InstanceContentSelectionHandler.Mode.ON_HOVER.toString());
    }/* ww w  .  j  ava2 s  . c  o m*/
    if (getDataPoint() != null) {
        Logger.getLogger(getClass().getName()).info("Data point is not null!");
        Point p = null;
        if (ke.getKeyCode() == KeyEvent.VK_RIGHT) {
            p = new Point(getDataPoint());
            p.translate(1, 0);
        } else if (ke.getKeyCode() == KeyEvent.VK_LEFT) {
            p = new Point(getDataPoint());
            p.translate(-1, 0);
        } else if (ke.getKeyCode() == KeyEvent.VK_UP) {
            p = new Point(getDataPoint());
            p.translate(0, 1);
        } else if (ke.getKeyCode() == KeyEvent.VK_DOWN) {
            p = new Point(getDataPoint());
            p.translate(0, -1);
        }
        setDataPoint(p);
        if (!ke.isShiftDown()) {
            //                triggerMSUpdate();
        }
    }
}

From source file:ch.zhaw.iamp.rct.ui.GrammarWindow.java

private void initialisationTextPaneKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_initialisationTextPaneKeyReleased
    if (evt != null && isArrowKeyCode(evt.getKeyCode())) {
        return;/* w w  w .j a  va  2  s. c o m*/
    }

    try {
        initialisationParser.parse(initialisationTextPane.getText());
    } catch (Exception ex) {
        System.out.println("Caught exception during parsing: " + ex.getMessage());
        return;
    }

    initialisationTextPane.getHighlighter().removeAllHighlights();

    if (initialisationParser.hasErrors()) {
        for (ParserError error : initialisationParser.getErrors()) {
            highlightErrorLine(error.getLineIndex(), initialisationTextPane);
        }
    } else {
        initialisationOutputTextArea.setText(initialisationParser.getOutputString());
        graphDeveloper = new GraphDeveloper(grammarParser, initialisationParser.getOutputString());
        graphDeveloper.develop();
        graphPanel.repaint();
    }
}

From source file:visolate.Visolate.java

public void keyReleased(KeyEvent e) {

    switch (e.getKeyCode()) {

    case KeyEvent.VK_F:
        startProcess(new FatnessProcessor(this));
        break;/*w  w  w . j a v a2 s .com*/

    case KeyEvent.VK_D:
        model.dump();
        break;

    case KeyEvent.VK_I: {

        System.out.println(selectedNets.size() + " selected nets:");

        for (Net net : selectedNets) {
            net.dump();
        }

        break;
    }

    case KeyEvent.VK_DELETE: {

        for (Net net : selectedNets) {

            Set<Net> superNet = net.getSuperNet();

            if (superNet == null) {
                model.deleteNet(net);
            } else {
                for (Iterator<Net> jt = superNet.iterator(); jt.hasNext();) {
                    model.deleteNet(jt.next());
                }
            }
        }

        undoHistory.add(0, new UndoDelete(selectedNets));

        clearSelection();

        break;
    }

    case KeyEvent.VK_U: {

        if (!undoHistory.isEmpty()) {

            Iterator<UndoTask> it = undoHistory.iterator();

            UndoTask undoTask = it.next();
            it.remove();

            undoTask.undo();
        }

        break;
    }
    }
}

From source file:org.scify.talkandplay.gui.users.UserFormPanel.java

/**
 * The action listeners for the text fields and radio buttons
 *//*ww w.j a va2  s .co m*/
private void setActionListeners() {
    selectionSensorTextField1.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent me) {
            if (selectionSensorTextField1.isEnabled()) {
                selectionSensor = new MouseSensor(me.getButton(), me.getClickCount(), "mouse");
                navigationSensor = null;
                selectionSensorTextField1.setText(setSensorText(selectionSensor));
            }
        }
    });
    selectionSensorTextField1.addKeyListener(new KeyAdapter() {
        public void keyReleased(KeyEvent ke) {
            if (selectionSensorTextField1.isEnabled()) {
                selectionSensor = new KeyboardSensor(ke.getKeyCode(), String.valueOf(ke.getKeyChar()),
                        "keyboard");
                navigationSensor = null;
                selectionSensorTextField1.setText(setSensorText(selectionSensor));
            }
        }
    });

    navigationSensorTextField.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent me) {
            if (navigationSensorTextField.isEnabled()) {
                navigationSensor = new MouseSensor(me.getButton(), me.getClickCount(), "mouse");
                navigationSensorTextField.setText(setSensorText(navigationSensor));
            }
        }
    });
    navigationSensorTextField.addKeyListener(new KeyAdapter() {
        public void keyReleased(KeyEvent ke) {
            if (navigationSensorTextField.isEnabled()) {
                navigationSensor = new KeyboardSensor(ke.getKeyCode(), String.valueOf(ke.getKeyChar()),
                        "keyboard");
                navigationSensorTextField.setText(setSensorText(navigationSensor));
            }
        }
    });

    selectionSensorTextField2.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent me) {
            if (selectionSensorTextField2.isEnabled()) {
                selectionSensor = new MouseSensor(me.getButton(), me.getClickCount(), "mouse");
                selectionSensorTextField2.setText(setSensorText(selectionSensor));
            }
        }
    });
    selectionSensorTextField2.addKeyListener(new KeyAdapter() {
        public void keyReleased(KeyEvent ke) {
            if (selectionSensorTextField2.isEnabled()) {
                selectionSensor = new KeyboardSensor(ke.getKeyCode(), String.valueOf(ke.getKeyChar()),
                        "keyboard");
                selectionSensorTextField2.setText(setSensorText(selectionSensor));
            }
        }
    });

    backButton.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent me) {
            parent.changePanel(new MainPanel(parent));
        }
    });

    autoScanRadioButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            if (autoScanRadioButton.isSelected()) {
                disableTextField(selectionSensorTextField2);
                disableTextField(navigationSensorTextField);
                enableTextField(selectionSensorTextField1);
            }
        }
    });

    manualScanRadioButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            if (manualScanRadioButton.isSelected()) {
                disableTextField(selectionSensorTextField1);
                enableTextField(selectionSensorTextField2);
                enableTextField(navigationSensorTextField);
            }
        }
    });

}

From source file:edu.ku.brc.specify.tasks.subpane.lm.LifeMapperPane.java

/**
 * Creates the UI.//  w  w w.  j a v a  2  s  . co m
 */
@SuppressWarnings("unchecked")
protected void createUI() {
    currentSize = getCurrentSizeSquare();

    searchText = createTextField(25);
    searchSciNameBtn = createI18NButton("LM_SEARCH");
    list = new JList(listModel);
    imgDisplay = new ImageDisplay(IMG_WIDTH, IMG_HEIGHT, false, true);

    imgDisplay.setChangeListener(this);

    wwPanel = new WorldWindPanel(false);
    wwPanel.setPreferredSize(new Dimension(currentSize, currentSize));
    wwPanel.setZoomInMeters(600000.0);

    imgDisplay.setDoShowText(false);

    searchMyDataBtn = createI18NButton("LM_SRCH_SP_DATA");
    myDataTF = UIHelper.createTextField();

    CellConstraints cc = new CellConstraints();

    PanelBuilder pb1 = new PanelBuilder(new FormLayout("p,2px,f:p:g,2px,p", "p"));
    pb1.add(createI18NFormLabel("LM_SRCH_COL"), cc.xy(1, 1));
    pb1.add(searchText, cc.xy(3, 1));
    pb1.add(searchSciNameBtn, cc.xy(5, 1));

    PanelBuilder myPB = new PanelBuilder(new FormLayout("f:p:g,p", "p,2px,p,2px,p"));
    mySepComp = myPB.addSeparator(getResourceString("LM_MYDATA_TITLE"), cc.xyw(1, 1, 2));
    myPB.add(myDataTF, cc.xyw(1, 3, 2));
    myPB.add(searchMyDataBtn, cc.xy(2, 5));

    PanelBuilder pb2 = new PanelBuilder(new FormLayout("MAX(p;300px),2px,f:p:g", "f:p:g,20px,p"));
    pb2.add(createScrollPane(list), cc.xy(1, 1));
    pb2.add(myPB.getPanel(), cc.xy(1, 3));

    PanelBuilder pb3 = new PanelBuilder(new FormLayout("f:p:g,p,f:p:g", "f:p:g,p,4px,p,f:p:g"));
    pb3.add(createI18NLabel("LM_WRLD_OVRVW", SwingConstants.CENTER), cc.xy(2, 2));
    pb3.add(imgDisplay, cc.xy(2, 4));

    PanelBuilder pb4 = new PanelBuilder(new FormLayout("f:p:g,p,f:p:g", "f:p:g,p,4px,p,f:p:g"));
    pb4.add(createI18NLabel("LM_INTRACT_VW", SwingConstants.CENTER), cc.xy(2, 2));
    pb4.add(wwPanel, cc.xy(2, 4));

    PanelBuilder pb5 = new PanelBuilder(new FormLayout("f:p:g", "f:p:g,p,f:p:g"));
    pb5.add(pb3.getPanel(), cc.xy(1, 1));
    pb5.add(pb4.getPanel(), cc.xy(1, 3));

    PanelBuilder pb = new PanelBuilder(new FormLayout("p,8px,f:p:g", "p,8px,f:p:g"), this);
    pb.add(pb1.getPanel(), cc.xyw(1, 1, 3));
    pb.add(pb2.getPanel(), cc.xy(1, 3));
    pb.add(pb5.getPanel(), cc.xy(3, 3));

    updateMyDataUIState(false);

    searchText.addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ENTER) {
                searchSciNameBtn.doClick();
            }
        }
    });

    myDataTF.addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ENTER) {
                searchMyDataBtn.doClick();
            }
        }
    });

    list.addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                if (list.getSelectedIndex() == -1) {
                    wwPanel.reset();
                    imgDisplay.setImage(blueMarble);

                } else {
                    SwingWorker<Boolean, Boolean> worker = new SwingWorker<Boolean, Boolean>() {
                        @Override
                        protected Boolean doInBackground() throws Exception {
                            if (doResetWWPanel) {
                                wwPanel.reset();
                            }
                            doSearchOccur();
                            return null;
                        }

                        @Override
                        protected void done() {
                            imgDisplay.repaint();
                        }
                    };
                    worker.execute();
                }
            }
        }
    });

    searchMyDataBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    doSearchSpecifyData(myDataTF.getText().trim());
                }
            });

        }
    });

    searchSciNameBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            doSearchGenusSpecies();
        }
    });

    blueMarbleListener = new BufferedImageFetcherIFace() {
        @Override
        public void imageFetched(BufferedImage image) {
            blueMarble = image;
            imgDisplay.setImage(blueMarble);
        }

        @Override
        public void error() {
            blueMarbleTries++;
            if (blueMarbleTries < 5) {
                blueMarbleRetry();
            }
        }
    };

    blueMarbleURL = BG_URL + String.format("WIDTH=%d&HEIGHT=%d", IMG_WIDTH, IMG_HEIGHT);

    pointsMapImageListener = new BufferedImageFetcherIFace() {
        @Override
        public void imageFetched(final BufferedImage image) {
            if (renderImage == null) {
                renderImage = new BufferedImage(IMG_WIDTH, IMG_HEIGHT, BufferedImage.TYPE_INT_ARGB);
            }
            Graphics2D g2d = renderImage.createGraphics();
            if (g2d != null) {
                g2d.fillRect(0, 0, IMG_WIDTH, IMG_HEIGHT);
                if (blueMarble != null) {
                    g2d.drawImage(blueMarble, 0, 0, null);
                }
                if (image != null) {
                    g2d.drawImage(image, 0, 0, null);
                }
                g2d.dispose();

                imgDisplay.setImage(renderImage);
            }
        }

        @Override
        public void error() {
        }
    };
    blueMarbleRetry();
}

From source file:org.wandora.application.gui.topicpanels.webview.WebViewPanel.java

private void urlTextFieldKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_urlTextFieldKeyPressed
    //System.out.println("evt.getKeyCode() == "+evt.getKeyCode());
    if (webEngine != null && evt.getKeyCode() == 10) {
        final String u = toURL(urlTextField.getText());
        Platform.runLater(new Runnable() {
            @Override/* w w w  . j  a v  a 2  s  .  c o  m*/
            public void run() {
                urlTextField.setBackground(Color.WHITE);
                webEngine.load(u);
            }
        });
    }
}

From source file:edu.ku.brc.specify.conversion.CustomDBConverterPanel.java

/**
 * Creates a Document dbConverterListener so the UI is updated when the doc changes
 * @param uiComponent the text field to be changed
 *//*w ww. j a  va 2  s . co  m*/
protected void addKeyListenerFor(final JComponent comp, final boolean checkForRet) {
    class KeyAdp extends KeyAdapter {
        private boolean checkForRetLocal = false;

        public KeyAdp(final boolean checkForRetArg) {
            this.checkForRetLocal = checkForRetArg;
        }

        @Override
        public void keyPressed(KeyEvent e) {
            updateUIControls();
            if (checkForRetLocal && e.getKeyCode() == KeyEvent.VK_ENTER) {
                doLogin();
            }
        }
    }

    comp.addKeyListener(new KeyAdp(checkForRet));
}