Example usage for java.awt.event KeyEvent VK_ESCAPE

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

Introduction

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

Prototype

int VK_ESCAPE

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

Click Source Link

Document

Constant for the ESCAPE virtual key.

Usage

From source file:org.languagetool.gui.ConfigurationDialog.java

public boolean show(List<Rule> rules) {
    configChanged = false;/*ww  w.j a va 2s. c  o m*/
    if (original != null) {
        config.restoreState(original);
    }
    dialog = new JDialog(owner, true);
    dialog.setTitle(messages.getString("guiConfigWindowTitle"));
    // close dialog when user presses Escape key:
    KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
    ActionListener actionListener = new ActionListener() {
        @Override
        public void actionPerformed(@SuppressWarnings("unused") ActionEvent actionEvent) {
            dialog.setVisible(false);
        }
    };
    JRootPane rootPane = dialog.getRootPane();
    rootPane.registerKeyboardAction(actionListener, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);

    configurableRules.clear();

    Language lang = config.getLanguage();
    if (lang == null) {
        lang = Languages.getLanguageForLocale(Locale.getDefault());
    }

    String specialTabNames[] = config.getSpecialTabNames();
    int numConfigTrees = 2 + specialTabNames.length;
    configTree = new JTree[numConfigTrees];
    JPanel checkBoxPanel[] = new JPanel[numConfigTrees];
    DefaultMutableTreeNode rootNode;
    GridBagConstraints cons;

    for (int i = 0; i < numConfigTrees; i++) {
        checkBoxPanel[i] = new JPanel();
        cons = new GridBagConstraints();
        checkBoxPanel[i].setLayout(new GridBagLayout());
        cons.anchor = GridBagConstraints.NORTHWEST;
        cons.gridx = 0;
        cons.weightx = 1.0;
        cons.weighty = 1.0;
        cons.fill = GridBagConstraints.HORIZONTAL;
        Collections.sort(rules, new CategoryComparator());
        if (i == 0) {
            rootNode = createTree(rules, false, null); //  grammar options
        } else if (i == 1) {
            rootNode = createTree(rules, true, null); //  Style options
        } else {
            rootNode = createTree(rules, true, specialTabNames[i - 2]); //  Special tab options
        }
        configTree[i] = new JTree(getTreeModel(rootNode));

        configTree[i].applyComponentOrientation(ComponentOrientation.getOrientation(lang.getLocale()));

        configTree[i].setRootVisible(false);
        configTree[i].setEditable(false);
        configTree[i].setCellRenderer(new CheckBoxTreeCellRenderer());
        TreeListener.install(configTree[i]);
        checkBoxPanel[i].add(configTree[i], cons);
        configTree[i].addMouseListener(getMouseAdapter());
    }

    JPanel portPanel = new JPanel();
    portPanel.setLayout(new GridBagLayout());
    cons = new GridBagConstraints();
    cons.insets = new Insets(0, 4, 0, 0);
    cons.gridx = 0;
    cons.gridy = 0;
    cons.anchor = GridBagConstraints.WEST;
    cons.fill = GridBagConstraints.NONE;
    cons.weightx = 0.0f;
    if (!insideOffice) {
        createNonOfficeElements(cons, portPanel);
    } else {
        createOfficeElements(cons, portPanel);
    }

    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new GridBagLayout());
    JButton okButton = new JButton(Tools.getLabel(messages.getString("guiOKButton")));
    okButton.setMnemonic(Tools.getMnemonic(messages.getString("guiOKButton")));
    okButton.setActionCommand(ACTION_COMMAND_OK);
    okButton.addActionListener(this);
    JButton cancelButton = new JButton(Tools.getLabel(messages.getString("guiCancelButton")));
    cancelButton.setMnemonic(Tools.getMnemonic(messages.getString("guiCancelButton")));
    cancelButton.setActionCommand(ACTION_COMMAND_CANCEL);
    cancelButton.addActionListener(this);
    cons = new GridBagConstraints();
    cons.insets = new Insets(0, 4, 0, 0);
    buttonPanel.add(okButton, cons);
    buttonPanel.add(cancelButton, cons);

    JTabbedPane tabpane = new JTabbedPane();

    JPanel jPane = new JPanel();
    jPane.setLayout(new GridBagLayout());
    cons = new GridBagConstraints();
    cons.insets = new Insets(4, 4, 4, 4);

    cons.gridx = 0;
    cons.gridy = 0;
    cons.weightx = 10.0f;
    cons.weighty = 0.0f;
    cons.fill = GridBagConstraints.NONE;
    cons.anchor = GridBagConstraints.NORTHWEST;
    cons.gridy++;
    cons.anchor = GridBagConstraints.WEST;
    jPane.add(getMotherTonguePanel(cons), cons);

    if (insideOffice) {
        cons.gridy += 3;
    } else {
        cons.gridy++;
    }
    cons.anchor = GridBagConstraints.WEST;
    jPane.add(getNgramPanel(cons), cons);

    cons.gridy++;
    cons.anchor = GridBagConstraints.WEST;
    jPane.add(getWord2VecPanel(cons), cons);

    cons.gridy++;
    cons.anchor = GridBagConstraints.WEST;
    jPane.add(portPanel, cons);
    cons.fill = GridBagConstraints.HORIZONTAL;
    cons.anchor = GridBagConstraints.WEST;
    for (JPanel extra : extraPanels) {
        //in case it wasn't in a containment hierarchy when user changed L&F
        SwingUtilities.updateComponentTreeUI(extra);
        cons.gridy++;
        jPane.add(extra, cons);
    }

    cons.gridy++;
    cons.fill = GridBagConstraints.BOTH;
    cons.weighty = 1.0f;
    jPane.add(new JPanel(), cons);

    tabpane.addTab(messages.getString("guiGeneral"), jPane);

    jPane = new JPanel();
    jPane.setLayout(new GridBagLayout());
    cons = new GridBagConstraints();
    cons.insets = new Insets(4, 4, 4, 4);
    cons.gridx = 0;
    cons.gridy = 0;
    cons.weightx = 10.0f;
    cons.weighty = 10.0f;
    cons.fill = GridBagConstraints.BOTH;
    jPane.add(new JScrollPane(checkBoxPanel[0]), cons);
    cons.weightx = 0.0f;
    cons.weighty = 0.0f;

    cons.gridx = 0;
    cons.gridy++;
    cons.fill = GridBagConstraints.NONE;
    cons.anchor = GridBagConstraints.LINE_END;
    jPane.add(getTreeButtonPanel(0), cons);

    tabpane.addTab(messages.getString("guiGrammarRules"), jPane);

    jPane = new JPanel();
    jPane.setLayout(new GridBagLayout());
    cons = new GridBagConstraints();
    cons.insets = new Insets(4, 4, 4, 4);
    cons.gridx = 0;
    cons.gridy = 0;
    cons.weightx = 10.0f;
    cons.weighty = 10.0f;
    cons.fill = GridBagConstraints.BOTH;
    jPane.add(new JScrollPane(checkBoxPanel[1]), cons);
    cons.weightx = 0.0f;
    cons.weighty = 0.0f;

    cons.gridx = 0;
    cons.gridy++;
    cons.fill = GridBagConstraints.NONE;
    cons.anchor = GridBagConstraints.LINE_END;
    jPane.add(getTreeButtonPanel(1), cons);

    cons.gridx = 0;
    cons.gridy++;
    cons.weightx = 5.0f;
    cons.weighty = 5.0f;
    cons.fill = GridBagConstraints.BOTH;
    cons.anchor = GridBagConstraints.WEST;
    jPane.add(new JScrollPane(getSpecialRuleValuePanel()), cons);

    tabpane.addTab(messages.getString("guiStyleRules"), jPane);

    for (int i = 0; i < specialTabNames.length; i++) {
        jPane = new JPanel();
        jPane.setLayout(new GridBagLayout());
        cons = new GridBagConstraints();
        cons.insets = new Insets(4, 4, 4, 4);
        cons.gridx = 0;
        cons.gridy = 0;
        cons.weightx = 10.0f;
        cons.weighty = 10.0f;
        cons.fill = GridBagConstraints.BOTH;
        jPane.add(new JScrollPane(checkBoxPanel[i + 2]), cons);
        cons.weightx = 0.0f;
        cons.weighty = 0.0f;

        cons.gridx = 0;
        cons.gridy++;
        cons.fill = GridBagConstraints.NONE;
        cons.anchor = GridBagConstraints.LINE_END;
        jPane.add(getTreeButtonPanel(i + 2), cons);

        tabpane.addTab(specialTabNames[i], jPane);
    }

    jPane = new JPanel();
    jPane.setLayout(new GridBagLayout());
    cons = new GridBagConstraints();
    cons.insets = new Insets(4, 4, 4, 4);
    cons.gridx = 0;
    cons.gridy = 0;
    if (insideOffice) {
        JLabel versionText = new JLabel(messages.getString("guiUColorHint"));
        versionText.setForeground(Color.blue);
        jPane.add(versionText, cons);
        cons.gridy++;
    }

    cons.weightx = 2.0f;
    cons.weighty = 2.0f;
    cons.fill = GridBagConstraints.BOTH;

    jPane.add(new JScrollPane(getUnderlineColorPanel(rules)), cons);

    Container contentPane = dialog.getContentPane();
    contentPane.setLayout(new GridBagLayout());
    cons = new GridBagConstraints();
    cons.insets = new Insets(4, 4, 4, 4);
    cons.gridx = 0;
    cons.gridy = 0;
    cons.weightx = 10.0f;
    cons.weighty = 10.0f;
    cons.fill = GridBagConstraints.BOTH;
    cons.anchor = GridBagConstraints.NORTHWEST;
    contentPane.add(tabpane, cons);
    cons.weightx = 0.0f;
    cons.weighty = 0.0f;
    cons.gridy++;
    cons.fill = GridBagConstraints.NONE;
    cons.anchor = GridBagConstraints.EAST;
    contentPane.add(buttonPanel, cons);

    dialog.pack();
    // center on screen:
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    Dimension frameSize = dialog.getSize();
    dialog.setLocation(screenSize.width / 2 - frameSize.width / 2,
            screenSize.height / 2 - frameSize.height / 2);
    dialog.setLocationByPlatform(true);
    //  add Color tab after dimension was set
    tabpane.addTab(messages.getString("guiUnderlineColor"), jPane);

    for (JPanel extra : this.extraPanels) {
        if (extra instanceof SavablePanel) {
            ((SavablePanel) extra).componentShowing();
        }
    }
    dialog.setVisible(true);
    return configChanged;
}

From source file:edu.ku.brc.ui.tmanfe.SearchReplacePanel.java

/**
 * sets up the keystroke mappings for "Ctrl-F" firing the find/replace panel
 * Escape making it disappear, and enter key firing a search
 *//*  w w w. ja va  2  s .  c o m*/
private void setupKeyStrokeMappings() {
    //table.getActionMap().clear();

    //override the "Ctrl-F" function for launching the find dialog shipped with JXTable
    table.getInputMap().put(
            KeyStroke.getKeyStroke(KeyEvent.VK_F, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()),
            UIRegistry.getResourceString(FIND));
    table.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_F, InputEvent.CTRL_MASK),
            UIRegistry.getResourceString(FIND));

    //create action that will display the find/replace dialog
    launchFindAction = new LaunchFindAction();
    table.getActionMap().put(FIND, launchFindAction);

    //Allow ESC buttun to call DisablePanelAction   
    String CANCEL_KEY = "CANCELKEY"; // i18n
    //Allow ENTER button to SearchAction
    String ENTER_KEY = "ENTERKEY"; // i18n
    String REPLACE_KEY = "REPLACEKEY"; // i18n

    KeyStroke enterKey = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, false);
    KeyStroke escapeKey = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false);

    InputMap textFieldInputMap = findField.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    textFieldInputMap.put(enterKey, ENTER_KEY);
    textFieldInputMap.put(escapeKey, CANCEL_KEY);

    ActionMap textFieldActionMap = findField.getActionMap();
    textFieldActionMap.put(ENTER_KEY, searchAction);
    textFieldActionMap.put(CANCEL_KEY, hideFindPanelAction);

    if (!table.isReadOnly()) {
        InputMap replaceFieldInputMap = replaceField.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
        replaceFieldInputMap.put(enterKey, REPLACE_KEY);
        replaceFieldInputMap.put(escapeKey, CANCEL_KEY);

        ActionMap replaceFieldActionMap = replaceField.getActionMap();
        replaceFieldActionMap.put(REPLACE_KEY, replaceAction);
        replaceFieldActionMap.put(CANCEL_KEY, hideFindPanelAction);
    }
}

From source file:com.github.benchdoos.weblocopener.updater.gui.UpdateDialog.java

private void createGUI() {
    setContentPane(contentPane);/*from   w w  w  .jav a 2 s  . c om*/
    getRootPane().setDefaultButton(buttonOK);
    if (IS_WINDOWS_XP) {
        //for windows xp&server 2003
        setIconImage(Toolkit.getDefaultToolkit()
                .getImage(UpdateDialog.class.getResource("/images/updaterIcon64_white.png")));
    } else {
        setIconImage(Toolkit.getDefaultToolkit()
                .getImage(UpdateDialog.class.getResource("/images/updaterIcon64.png")));

    }

    createDefaultActionListeners();

    // call onCancel() when cross is clicked
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            onCancel();
        }
    });

    // call onCancel() on ESCAPE
    contentPane.registerKeyboardAction(e -> onCancel(), KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
            JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);

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

    updateInfoButton.setCursor(new Cursor(Cursor.HAND_CURSOR));

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

        private void openSetupUrl() {
            log.debug("Calling to download setup manually");
            URL url = null;
            if (updater != null) {
                if (updater.getAppVersion() != null) {
                    try {
                        log.debug("Trying to open [" + updater.getAppVersion().getDownloadUrl() + "]");
                        url = new URL(updater.getAppVersion().getDownloadUrl());
                        UrlValidator urlValidator = new UrlValidator();
                        UserUtils.openWebUrl(url);
                    } catch (MalformedURLException e1) {
                        openWebsite(url);
                    }
                } else
                    UserUtils.openWebUrl(ApplicationConstants.UPDATE_WEB_URL);

            } else
                UserUtils.openWebUrl(ApplicationConstants.UPDATE_WEB_URL);
        }

        private void openWebsite(URL url) {
            log.warn("Could not open setup url: [" + url + "]\n" + "Opening "
                    + ApplicationConstants.UPDATE_WEB_URL);
            UserUtils.openWebUrl(ApplicationConstants.UPDATE_WEB_URL);
        }
    });

    pack();
    setLocation(FrameUtils.getFrameOnCenterLocationPoint(this));
    setSize(new Dimension(400, 170));
    setResizable(false);
}

From source file:nz.govt.natlib.ndha.manualdeposit.dialogs.EnterEntityNameAndPrefix.java

private void txtEnterEntityNameKeyPressed(final java.awt.event.KeyEvent evt) {
    if (evt.getKeyCode() == KeyEvent.VK_ESCAPE) {
        cancel();
    }
}

From source file:org.rdv.ui.ChannelListPanel.java

/**
 * Create the UI panel that contains the controls to filter the channel list.
 * //from   w  w w .  j  av  a 2s.c om
 * @return  the UI component dealing with filtering
 */
private JComponent createFilterPanel() {
    JPanel filterPanel = new JPanel();
    filterPanel.setLayout(new BorderLayout(5, 5));
    filterPanel.setBackground(Color.white);
    filterPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    JLabel filterIconLabel = new JLabel(DataViewer.getIcon("icons/filter.gif"));
    filterPanel.add(filterIconLabel, BorderLayout.WEST);

    filterTextField = new JTextField();
    filterTextField.setToolTipText("Enter text here to filter the channel list");
    filterTextField.getDocument().addDocumentListener(new DocumentListener() {
        public void changedUpdate(DocumentEvent e) {
            treeModel.setFilter(filterTextField.getText());
        }

        public void insertUpdate(DocumentEvent e) {
            changedUpdate(e);
        }

        public void removeUpdate(DocumentEvent e) {
            changedUpdate(e);
        }
    });
    filterPanel.add(filterTextField, BorderLayout.CENTER);

    Action focusFilterAction = new AbstractAction() {
        /** serialization version identifier */
        private static final long serialVersionUID = -2443410059209958411L;

        public void actionPerformed(ActionEvent e) {
            filterTextField.requestFocusInWindow();
            filterTextField.selectAll();
        }
    };

    int modifier = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
    filterTextField.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
            .put(KeyStroke.getKeyStroke(KeyEvent.VK_F, modifier), "focusFilter");
    filterTextField.getActionMap().put("focusFilter", focusFilterAction);

    Action cancelFilterAction = new AbstractAction(null, DataViewer.getIcon("icons/cancel.gif")) {
        /** serialization version identifier */
        private static final long serialVersionUID = 8913797349366699615L;

        public void actionPerformed(ActionEvent e) {
            treeModel.setFilter(null);
        }
    };
    cancelFilterAction.putValue(Action.SHORT_DESCRIPTION, "Cancel filter");

    filterTextField.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "cancelFilter");
    filterTextField.getActionMap().put("cancelFilter", cancelFilterAction);

    clearFilterButton = new JButton(cancelFilterAction);
    clearFilterButton.setBorderPainted(false);
    clearFilterButton.setVisible(false);
    filterPanel.add(clearFilterButton, BorderLayout.EAST);

    return filterPanel;
}

From source file:org.piraso.ui.base.ContextMonitorTopComponent.java

private void initKeyboardActions() {
    Action findAction = new AbstractAction() {
        @Override//from  w  ww  .  j  a va  2 s.  c o  m
        public void actionPerformed(ActionEvent e) {
            searcher.reset();
            btnSearch.setSelected(!btnSearch.isSelected());
            btnSearchActionPerformed(e);
        }
    };

    Action nextAction = new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            btnNextActionPerformed(e);
        }
    };

    KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_F, InputEvent.META_MASK);
    registerKeyboardAction(findAction, stroke, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);

    stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
    txtSearch.registerKeyboardAction(findAction, stroke, JComponent.WHEN_FOCUSED);

    stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
    txtSearch.registerKeyboardAction(nextAction, stroke, JComponent.WHEN_FOCUSED);
}

From source file:net.sf.jabref.gui.FindUnlinkedFilesDialog.java

/**
 * Close dialog when pressing escape//www  .  ja  v  a  2s .  c  om
 */
@Override
protected JRootPane createRootPane() {
    ActionListener actionListener = actionEvent -> setVisible(false);
    JRootPane rPane = new JRootPane();
    KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
    rPane.registerKeyboardAction(actionListener, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);

    return rPane;
}

From source file:org.pmedv.core.dialogs.AbstractNiceDialog.java

protected JRootPane createRootPane() {
    ActionListener actionListener = new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {

            result = OPTION_CANCEL;//from   www  .  j  av  a  2  s  .  c  om

            setVisible(false);
        }
    };
    JRootPane rootPane = new JRootPane();
    KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
    rootPane.registerKeyboardAction(actionListener, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);
    return rootPane;
}

From source file:edu.ku.brc.af.ui.forms.validation.ValComboBox.java

/**
 * @param makeEditable/*w w  w.ja va2 s.  co  m*/
 */
public void init(final boolean makeEditable) {
    if (makeEditable) {
        Java2sAutoComboBox cbx = (Java2sAutoComboBox) comboBox;
        textEditor = cbx.getAutoTextFieldEditor().getAutoTextFieldEditor();
        textEditor.addKeyListener(getTextKeyAdapter());
        addPopupMenu(textEditor);

        comboBox.addKeyListener(new KeyAdapter() {

            @Override
            public void keyPressed(KeyEvent e) {
                super.keyPressed(e);
                if (e.getKeyCode() == KeyEvent.VK_ESCAPE || e.getKeyCode() == KeyEvent.VK_DELETE
                        || e.getKeyCode() == KeyEvent.VK_BACK_SPACE) {
                    comboBox.setSelectedIndex(-1);
                }
                notifyChangeListeners(new ChangeEvent(ValComboBox.this));
            }

            @Override
            public void keyReleased(KeyEvent e) {
                if (e.getKeyCode() == KeyEvent.VK_ESCAPE || e.getKeyCode() == KeyEvent.VK_DELETE
                        || e.getKeyCode() == KeyEvent.VK_BACK_SPACE) {
                    comboBox.setSelectedIndex(-1);
                }
                super.keyReleased(e);
            }

            /* (non-Javadoc)
             * @see java.awt.event.KeyAdapter#keyTyped(java.awt.event.KeyEvent)
             */
            @Override
            public void keyTyped(KeyEvent e) {
                if (e.getKeyCode() == KeyEvent.VK_ESCAPE || e.getKeyCode() == KeyEvent.VK_DELETE
                        || e.getKeyCode() == KeyEvent.VK_BACK_SPACE) {
                    comboBox.setSelectedIndex(-1);
                }
                super.keyTyped(e);
            }

        });
    }

    setOpaque(false);

    if (defaultTextBGColor == null) {
        defaultTextBGColor = (new JTextField()).getBackground();
    }

    setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));

    PanelBuilder builder = new PanelBuilder(new FormLayout("f:p:g", "p:g:f"), this);
    CellConstraints cc = new CellConstraints();
    builder.add(comboBox, cc.xy(1, 1));

    comboBox.getModel().addListDataListener(this);

    if (valTextColor == null || requiredFieldColor == null) {
        valTextColor = AppPrefsCache.getColorWrapper("ui", "formatting", "valtextcolor");
        requiredFieldColor = AppPrefsCache.getColorWrapper("ui", "formatting", "requiredfieldcolor");
    }
    if (valTextColor != null) {
        AppPrefsCache.addChangeListener("ui.formatting.valtextcolor", this);
        AppPrefsCache.addChangeListener("ui.formatting.requiredfieldcolor", this);
    }
}

From source file:org.kalypso.kalypsomodel1d2d.ui.map.channeledit.DrawBanklineWidget.java

@Override
public void keyPressed(final KeyEvent e) {
    final int keyCode = e.getKeyCode();

    switch (keyCode) {
    case KeyEvent.VK_ESCAPE:
        reinit();/*from  w  w w  .j a v a2  s  .c om*/
        break;

    case KeyEvent.VK_DELETE:
    case KeyEvent.VK_BACK_SPACE:
        if (m_lineBuilder != null && !m_edit)
            m_lineBuilder.removeLastPoint();
        break;

    // switch mode
    case KeyEvent.VK_SPACE:
        if (m_edit == true)
            m_edit = false;
        else {
            m_edit = true;
            if (m_bankline != null & m_lineEditor == null)
                m_lineEditor = new LineGeometryEditor(new GM_Curve[] { m_bankline }, m_bankline, getMapPanel());
        }
        break;
    }

    repaintMap();
}