Example usage for java.awt.event KeyEvent VK_DELETE

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

Introduction

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

Prototype

int VK_DELETE

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

Click Source Link

Document

Constant for the delete key.

Usage

From source file:tax.MainForm.java

private void afmTextKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_afmTextKeyPressed
    String text = afmText.getText();

    if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
        if (text.length() == 9) {

            for (Object key : afmToName.keySet()) {
                if (afmToName.get(key).equals(text))
                    nameText.setText(key.toString());
            }/*from  w  w w  .j ava  2s. c  om*/

            //                Util.fadeInAndOut(afmText, Util.darkGreen);
            addRowBut.doClick();
        } else if (text.length() == 0) {
            Util.fadeInAndOut(afmText, Color.white);
            nameText.setEnabled(true);
            nameText.requestFocus();
        } else
            Util.fadeInAndOut(afmText, Util.darkOrange);
    } else if (!evt.isActionKey() && !evt.isAltDown() && !evt.isControlDown() && !evt.isShiftDown()
            && !evt.isMetaDown() && (evt.getKeyCode() != KeyEvent.VK_BACK_SPACE)
            && (evt.getKeyCode() != KeyEvent.VK_DELETE) && (evt.getKeyCode() != KeyEvent.VK_ESCAPE)) {
        EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                String text = afmText.getText();
                int afmLength = text.length();

                while (lastAFMTextLength == afmLength) {
                    try {
                        Thread.sleep(100);
                        System.out.println("text: " + text);
                        System.out.println(lastAFMTextLength + " " + afmLength);
                        return;
                    } catch (InterruptedException ex) {
                        Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE, null, ex);
                    }
                    text = afmText.getText();
                    afmLength = text.length();
                }

                try {
                    int num = Integer.decode(text);
                    if (afmLength > 9) {
                        if (text.length() > 0)
                            afmText.setText(text.substring(0, afmLength - 1));
                        else
                            afmText.setText("");
                        return;
                    }
                } catch (Exception e) {
                    if (text.length() > 0)
                        afmText.setText(text.substring(0, afmLength - 1));
                    else
                        afmText.setText("");
                    return;
                }

                lastAFMTextLength = afmLength;
            }
        });
    }
}

From source file:tax.MainForm.java

private void afmTextSKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_afmTextSKeyPressed
    if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
        String text = afmTextS.getText();

        if (text.length() == 9) {
            try {
                int num = Integer.parseInt(text);
            } catch (Exception e) {
                afmTextS.setText("");
                return;
            }/* ww w  .j ava 2s.  c o  m*/

            //                Util.fadeInAndOut(afmTextS, Util.darkGreen);
            addNameBut.doClick();
        } else {
            Util.fadeInAndOut(afmTextS, Util.darkOrange);
        }
    } else if (!evt.isActionKey() && !evt.isAltDown() && !evt.isControlDown() && !evt.isShiftDown()
            && !evt.isMetaDown() && (evt.getKeyCode() != KeyEvent.VK_BACK_SPACE)
            && (evt.getKeyCode() != KeyEvent.VK_DELETE) && (evt.getKeyCode() != KeyEvent.VK_ESCAPE)) {
        EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                String text = afmTextS.getText();
                int afmLength = text.length();

                while (lastAFMTextSLength == afmLength) {
                    try {
                        Thread.sleep(100);
                        System.out.println("text: " + text);
                        System.out.println(lastAFMTextSLength + " " + afmLength);
                        return;
                    } catch (InterruptedException ex) {
                        Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE, null, ex);
                    }
                    text = afmTextS.getText();
                    afmLength = text.length();
                }

                try {
                    int num = Integer.decode(text);
                    if (afmLength > 9) {
                        if (text.length() > 0)
                            afmTextS.setText(text.substring(0, afmLength - 1));
                        else
                            afmTextS.setText("");
                        return;
                    }
                } catch (Exception e) {
                    if (text.length() > 0)
                        afmTextS.setText(text.substring(0, afmLength - 1));
                    else
                        afmTextS.setText("");
                    return;
                }

                lastAFMTextSLength = afmLength;
            }
        });
    }
}

From source file:tax.MainForm.java

private void dateTextKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_dateTextKeyReleased
    int keyCode = evt.getKeyCode();
    if ((keyCode == KeyEvent.VK_BACK_SPACE) || (keyCode == KeyEvent.VK_DELETE)) {
        lastDateTextLength = dateText.getText().length();
    }/*from  w  ww . j a  v a2  s  .  c om*/
}

From source file:tax.MainForm.java

private void afmTextKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_afmTextKeyReleased
    int keyCode = evt.getKeyCode();
    if ((keyCode == KeyEvent.VK_BACK_SPACE) || (keyCode == KeyEvent.VK_DELETE)) {
        lastDateTextLength = dateText.getText().length();
    }//  w  w w  .j  a v  a2 s .co m
}

From source file:tax.MainForm.java

private void afmTextSKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_afmTextSKeyReleased
    int keyCode = evt.getKeyCode();
    if ((keyCode == KeyEvent.VK_BACK_SPACE) || (keyCode == KeyEvent.VK_DELETE)) {
        lastDateTextLength = dateText.getText().length();
    }/*w  w w  .j av a  2s .c  om*/
}

From source file:tax.MainForm.java

private void priceTextKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_priceTextKeyReleased
    int keyCode = evt.getKeyCode();
    if ((keyCode == KeyEvent.VK_BACK_SPACE) || (keyCode == KeyEvent.VK_DELETE)) {
        lastDateTextLength = dateText.getText().length();
    }/*ww w.j  av a2s.  c o  m*/
}

From source file:tvbrowser.extras.favoritesplugin.dlgs.FavoriteTreeModel.java

public void updatePluginTree(final PluginTreeNode node, final ArrayList<Program> allPrograms,
        FavoriteNode parentFavorite) {//from   w w  w .  ja v a 2  s  .  c  o  m
    if (parentFavorite == null) {
        parentFavorite = (FavoriteNode) getRoot();
    }

    if (parentFavorite.isDirectoryNode()) {
        @SuppressWarnings("unchecked")
        Enumeration<FavoriteNode> e = parentFavorite.children();

        while (e.hasMoreElements()) {
            final FavoriteNode child = e.nextElement();

            if (child.isDirectoryNode()) {
                PluginTreeNode newNode = new PluginTreeNode(child.toString());
                newNode.setGroupingByWeekEnabled(true);

                updatePluginTree(newNode, allPrograms, child);
                if (!newNode.isEmpty()) {
                    node.add(newNode);
                }
            } else {
                Program[] progArr = child.getFavorite().getWhiteListPrograms();
                if (progArr.length > 0) {
                    PluginTreeNode newNode = new PluginTreeNode(child.toString());
                    newNode.setGroupingByWeekEnabled(true);
                    newNode.getMutableTreeNode().setIcon(FavoritesPlugin.getFavoritesIcon(16));
                    node.add(newNode);
                    Action editFavorite = new AbstractAction() {
                        public void actionPerformed(ActionEvent e) {
                            FavoritesPlugin.getInstance().editFavorite(child.getFavorite());
                        }
                    };
                    editFavorite.putValue(Action.NAME, mLocalizer.ellipsisMsg("editTree", "Edit"));
                    editFavorite.putValue(Action.SMALL_ICON, TVBrowserIcons.edit(TVBrowserIcons.SIZE_SMALL));

                    Action deleteFavorite = new AbstractAction() {
                        public void actionPerformed(ActionEvent e) {
                            FavoritesPlugin.getInstance().askAndDeleteFavorite(child.getFavorite());
                        }
                    };
                    deleteFavorite.putValue(Action.NAME, mLocalizer.ellipsisMsg("deleteTree", "Delete"));
                    deleteFavorite.putValue(Action.SMALL_ICON,
                            TVBrowserIcons.delete(TVBrowserIcons.SIZE_SMALL));
                    deleteFavorite.putValue(ContextMenuIf.ACTIONKEY_KEYBOARD_EVENT, KeyEvent.VK_DELETE);

                    newNode.addAction(editFavorite);
                    newNode.addAction(deleteFavorite);

                    if (progArr.length <= 10) {
                        newNode.setGroupingByDateEnabled(false);
                    }
                    boolean episodeOnly = progArr.length > 1;
                    for (Program program : progArr) {
                        String episode = program.getTextField(ProgramFieldType.EPISODE_TYPE);
                        if (StringUtils.isBlank(episode)) {
                            episodeOnly = false;
                            break;
                        }
                    }

                    for (Program program : progArr) {
                        PluginTreeNode pNode = newNode.addProgramWithoutCheck(program);
                        allPrograms.add(program);
                        if (episodeOnly || progArr.length <= 10) {
                            pNode.setNodeFormatter(new NodeFormatter() {
                                public String format(ProgramItem pitem) {
                                    Program p = pitem.getProgram();
                                    return FavoriteTreeModel.getFavoriteLabel(child.getFavorite(), p);
                                }
                            });
                        }
                    }
                }
            }
        }
    }
}

From source file:view.MainWindow.java

private void jtOpenedDocumentsKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtOpenedDocumentsKeyPressed
    if (evt.getKeyCode() == KeyEvent.VK_DELETE) {
        closeDocument(true);/*from  ww  w .  ja  v  a2 s.  c o  m*/
    }
}

From source file:visolate.Visolate.java

public void keyReleased(KeyEvent e) {

    switch (e.getKeyCode()) {

    case KeyEvent.VK_F:
        startProcess(new FatnessProcessor(this));
        break;//from   w  w w  . jav  a 2 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:vista.ventas.DiagOrdenesDeCompra.java

private void eventosDeTeclas() {
    KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
    manager.addKeyEventDispatcher(new KeyEventDispatcher() {

        public boolean dispatchKeyEvent(KeyEvent e) {
            if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow().getClass()
                    .getSimpleName().equals("DiagOrdenesDeCompra")) {
                if (e.getID() == KeyEvent.KEY_PRESSED) {
                    if (e.getKeyCode() == KeyEvent.VK_F3) {
                        agregarArticulo();
                        calcularTotal();
                    }/* w ww . ja v a 2  s .com*/
                    if (e.getKeyCode() == KeyEvent.VK_F7) {
                        realizarVenta();
                    }
                    if (e.getKeyCode() == KeyEvent.VK_F4) {
                        cerrar();
                    }
                    if (e.getKeyCode() == KeyEvent.VK_DELETE && tblArticulos.getSelectedRow() != -1) {
                        quitarArticuloLista();
                    }

                }
            }

            return false;
        }
    });
}