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:ecorecyclesimulator.RmosGUI.java

private void validateForInteger(char input, java.awt.event.KeyEvent e) {

    if (!(Character.isDigit(input)) || (input == KeyEvent.VK_BACK_SPACE) || (input == KeyEvent.VK_DELETE)) {
        getToolkit().beep();//  w ww  .  j av  a 2  s.c  om
        e.consume();
    }
}

From source file:base.BasePlayer.Main.java

@Override

public void keyPressed(KeyEvent e) {
    keyCode = e.getKeyCode();/*w ww  .j  ava  2  s  .c om*/

    if (!Main.shift && (e.getModifiers() & KeyEvent.SHIFT_MASK) != 0) {

        Main.shift = true;
    } else if ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0) {
        Main.drawCanvas.ctrlpressed = 100;

        if (keyCode == KeyEvent.VK_S) {

            if (drawCanvas.drawVariables.projectName.equals("Untitled")) {
                saveProjectAs.doClick();
            } else {
                Serializer ser = new Serializer();
                ser.serialize(drawCanvas.drawVariables.projectFile);
            }
        }
        if (keyCode == KeyEvent.VK_W) {

            //   System.out.println("\n----\n");

            /*
               int[][] array = new int[Main.varsamples][VariantHandler.callSlider.getUpperValue()+1];
                       
                  for(int i = 0; i<array.length; i++) {
                     for(int j = 0; j<array[i].length; j++) {
             array[i][j] = 0;
                     }
                  }
                  /*VarNode node = FileRead.head.getNext();
                  int counter = 0;
                  while(node != null) {
                     if(!drawCanvas.hideNode(node)) {               
             counter++;
             for(int i = 0; i<node.vars.size(); i++) {
                if(!drawCanvas.hideNodeVar(node, node.vars.get(i))) {
                   for(int j = 0;j<node.vars.get(i).getValue().size(); j++) {
                      if(!drawCanvas.hideVar(node.vars.get(i).getValue().get(j), false)) {
                         array[node.vars.get(i).getValue().get(j).getSample().getIndex()][(int)(MethodLibrary.round(node.vars.get(i).getValue().get(j).getAlleleFraction()*100,2))]++;
                      }
                              
                   }
                           
                           
                }                  
             }
                     }
                       
                     node = node.getNext();
                  }*/
            /*   int width = Main.drawCanvas.getWidth()-Main.sidebarWidth;
                    
               JPopupMenu menu = new JPopupMenu();
            Plotter plotter = new Plotter(width);         
            plotter.setPreferredSize(new Dimension(width,400));
            menu.add(plotter);
            menu.pack();
            menu.show(Main.drawCanvas,Main.sidebarWidth, drawScroll.getVerticalScrollBar().getValue());
            */
        }
        if (keyCode == KeyEvent.VK_PLUS || keyCode == 107) {

            //      defaultFontSize++;

            //      setFonts();
        }
        if (keyCode == KeyEvent.VK_M || keyCode == KeyEvent.VK_MINUS || keyCode == 109) {

            //      defaultFontSize--;

            //      setFonts();
        }
        /*   else if(keyCode == KeyEvent.VK_M) {
              VarNode current = FileRead.head.getNext();
               while(current != null) {
                          
                  if(current.getNext() != null && current.getNext().getPosition()-current.getPosition() > 100000) {
        System.out.println(current.getPosition() +" " +(current.getNext().getPosition()-current.getPosition()));
                  }
                  current = current.getNext();
               }
               current = null;
           }
           */
    } else if (keyCode == KeyEvent.VK_DELETE) {
        if (Main.drawCanvas.selectedSample != null) {
            Main.drawCanvas.removeSample(Main.drawCanvas.selectedSample);
        }
    }
    /*   else if(keyCode == KeyEvent.VK_7) {
                  
                  
       }*/
    else if (keyCode == KeyEvent.VK_O && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) {
        /*   clearData();
                   
           try {
              FileInputStream fin = new FileInputStream("C:/HY-Data/RKATAINE/test.ses");
              ObjectInputStream ois = new ObjectInputStream(fin);
              drawCanvas.sampleList = (ArrayList<Sample>) ois.readObject();
              Main.samples = (short)drawCanvas.sampleList.size();
                      
              drawCanvas.splits = (ArrayList<SplitClass>) ois.readObject();
              for(int i = 0; i<drawCanvas.splits.size(); i++) {
                 drawCanvas.splits.get(i).resetSplits();
              }
              drawCanvas.drawVariables = (DrawVariables)ois.readObject();
                      
              ois.close();
              drawCanvas.resizeCanvas(Main.drawCanvas.getWidth(), Main.drawCanvas.getHeight());
                      
              Draw.setScrollbar(drawCanvas.drawVariables.scrollbarpos);
                      
              for(int i= 0; i<drawCanvas.splits.size(); i++) {
                 drawCanvas.splits.get(i).setCytoImage(null);
                 chromDraw.drawCyto(drawCanvas.splits.get(i));
                 chromDraw.updateExons = true;
                 FileRead.search = true;
                 drawCanvas.gotoPos(drawCanvas.splits.get(i).chrom, drawCanvas.splits.get(i).start, drawCanvas.splits.get(i).end);
                 chromDraw.repaint();
              }
              for(int i = 0 ;i<drawCanvas.sampleList.size(); i++) {
                 for(int r = 0 ;r<drawCanvas.sampleList.size(); r++) {
                    if(drawCanvas.sampleList.get(i).getreadHash().size() > 0) {
          drawCanvas.sampleList.get(i).resetreadHash();
                    }
                 }
              }
                   
           }
           catch(Exception ex) {
              ex.printStackTrace();
           }
           */
    }

    else if (keyCode == KeyEvent.VK_F9) {

        FileRead.head.putNext(null);
        drawCanvas.variantsStart = 0;
        drawCanvas.variantsEnd = 1;
        Draw.updatevars = true;
        Main.drawCanvas.repaint();

    } else if (keyCode == KeyEvent.VK_F11) {

        /*   try {
              BBFileReader reader = new BBFileReader( Main.bedCanvas.bedTrack.get(0).file.getCanonicalPath(),  Main.bedCanvas.bedTrack.get(0));
              int zoomlevel = 1;
              for(int i =2;i<reader.getZoomLevels().getZoomHeaderCount();i++) {
                 if(reader.getZoomLevels().getZoomLevelHeader(i).getReductionLevel() < (Main.drawCanvas.splits.get(0).viewLength/(Main.drawCanvas.splits.get(0).pixel*Main.drawCanvas.splits.get(0).viewLength))) {
                    zoomlevel = i;
                 }
                 else {
                    break;
                 }
              }
                      
                
                         
           }
           catch(Exception ex) {
              ex.printStackTrace();
           }*/
    } else if (keyCode == KeyEvent.VK_F12) {
        /*VarNode next = Main.drawCanvas.current.getNext();
                
        MethodLibrary.makeMultiAlt("2",next.getPosition(), "G", next);
                
           next = null;
        */
        /*   try {
              URL urli = new URL("ftp://ftp.ensembl.org/pub/grch37/update/gff3/homo_sapiens/Homo_sapiens.GRCh37.87.gff3.gz");
              System.out.println(urli.getProtocol() +" " +urli.getHost() +" " +urli.getPath().substring(0,urli.getPath().lastIndexOf("/")+1));
           }
           catch(Exception ex) {
              ex.printStackTrace();
           }*/
    } else if (keyCode == KeyEvent.VK_F8) {

        File file = new File(searchField.getText().replaceAll(" ", ""));
        if (!file.exists()) {
            if (Main.drawCanvas.splits.get(0).viewLength < 1000) {

                Main.getConsSeq();
            }
        } else {
            try {
                /*
                JFileChooser chooser = new JFileChooser(file.getPath());
                chooser.setAcceptAllFileFilterUsed(true);                       
                        
                chooser.setDialogTitle("Save FASTA file as...");
                int returnVal = chooser.showSaveDialog((Component)this.getParent());                   
                        
                if(returnVal == JFileChooser.APPROVE_OPTION) {  
                  String suffix = "";
                  if(!chooser.getSelectedFile().getName().endsWith(".fa") && !chooser.getSelectedFile().getName().endsWith(".fasta")) {
                     suffix = ".fa";
                  }
                          
                   File outfile = new File(chooser.getSelectedFile().getCanonicalPath() +suffix);   
                 //  File outfile = new File("test.fa");   
                   Main.nothread = true;
                  Main.noreadthread = true;
                  FileRead.search = true;   
                  Draw.variantcalculator = true;
                        
                  Seqfetcher fetcher = new Seqfetcher(file, outfile);
                  fetcher.execute();
                           
                }*/
            } catch (Exception ex) {
                ex.printStackTrace();
            }

        }

    } else if (keyCode == KeyEvent.VK_ENTER) {

        if (e.getSource() == searchField) {
            search(searchField.getText());

        }

    }

}

From source file:net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.BaseKeyTextHandler.java

/**
 * If the field is not allowed to have nulls, we need to let the 
 * user erase the entire contents of the field so that they can enter 
 * a brand-new value from scratch.  While the empty field is not a legal
 * value, we cannot avoid allowing it.  This is the normal editing behavior,
 * so we do not need to add anything special here except for the cyclic
 * re-entering of the original data if user hits delete when field is empty
 * /*from  www.j a v a2s .  co  m*/
 * @param text
 * @param c
 * @param e
 * @param _textComponent
 */
protected void handleNotNullableField(String text, char c, KeyEvent e,
        IRestorableTextComponent _textComponent) {
    if (text.length() == 0) {

        // We want to detect two empty text values in a row before 
        // we decide to restore the original value.  Since 'text'
        // contains the new value, we want to allow the first empty
        // 'text' so that the user can clear the field, and on the 
        // second one we will set it to the original value.
        if (firstBlankText) {
            firstBlankText = false;
            return;
        } else {
            firstBlankText = true;
        }

        if (c == KeyEvent.VK_BACK_SPACE || c == KeyEvent.VK_DELETE) {
            // delete when null => original value
            _textComponent.restoreText();
            e.consume();
        }
    }
}

From source file:nl.ru.ai.projects.parrot.biomav.editor.BehaviorEditor.java

public BehaviorEditor() {
    ///////// Graph stuff
    graphViewer.addKeyListener(new KeyListener() {
        @Override// ww w  . j  a  v a 2s.c  o m
        public void keyTyped(KeyEvent e) {
        }

        @Override
        public void keyReleased(KeyEvent e) {
        }

        @Override
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_DELETE) {
                for (TransitionEdge edge : graphViewer.getPickedEdgeState().getPicked()) {
                    graph.removeEdge(edge);
                }
                for (BehaviorVertex vertex : graphViewer.getPickedVertexState().getPicked()) {
                    graph.removeVertex(vertex);
                }
                e.consume();
                repaint();
            }
        }
    });

    graphViewer.setBackground(Color.GRAY);

    graphViewer.setGraphMouse(graphMouse);
    graphMouse.add(graphMouseEditPlugin);
    graphMouse.add(graphMouseTranslatePlugin);
    graphMouse.add(graphMousePickPlugin);

    // Set label renderer
    VertexLabelAsShapeRenderer<BehaviorVertex, TransitionEdge> renderer = new VertexLabelAsShapeRenderer<BehaviorVertex, TransitionEdge>(
            graphViewer.getRenderContext());
    graphViewer.getRenderContext().setVertexShapeTransformer(renderer);
    graphViewer.getRenderer().setVertexLabelRenderer(renderer);

    // Set label contents
    graphViewer.getRenderContext().setVertexLabelTransformer(new Transformer<BehaviorVertex, String>() {
        @Override
        public String transform(BehaviorVertex v) {
            return v.getSelectedBehavior();
        }
    });
    graphViewer.getRenderContext().setEdgeLabelTransformer(new Transformer<TransitionEdge, String>() {
        @Override
        public String transform(TransitionEdge e) {
            return e.getTransition();
        }
    });

    // Set fonts
    graphViewer.getRenderContext().setVertexFontTransformer(new Transformer<BehaviorVertex, Font>() {
        @Override
        public Font transform(BehaviorVertex v) {
            return new Font(graphViewer.getFont().getName(), graphViewer.getFont().getStyle(), 20);
        }
    });
    graphViewer.getRenderContext().setEdgeFontTransformer(new Transformer<TransitionEdge, Font>() {
        @Override
        public Font transform(TransitionEdge arg0) {
            return new Font(graphViewer.getFont().getName(), graphViewer.getFont().getStyle(), 16);
        }
    });

    // Fill color dependent on vertex activity
    graphViewer.getRenderContext().setVertexFillPaintTransformer(new Transformer<BehaviorVertex, Paint>() {
        @Override
        public Paint transform(BehaviorVertex vertex) {
            return vertex.isActive() ? Color.ORANGE : Color.RED;
        }
    });

    graphViewer.getPickedVertexState().addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            BehaviorVertex vertex = (BehaviorVertex) e.getItem();
            if (e.getStateChange() == ItemEvent.SELECTED) {
                setNewSelectedParameterControlInterface(vertex);
            }
            if (e.getStateChange() == ItemEvent.DESELECTED) {
                if (vertex == selectedPCInterface) {
                    setNewSelectedParameterControlInterface(null);
                }
            }
        }
    });
    graphViewer.getPickedEdgeState().addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            TransitionEdge edge = (TransitionEdge) e.getItem();
            if (e.getStateChange() == ItemEvent.SELECTED) {
                setNewSelectedParameterControlInterface(edge);
            }
            if (e.getStateChange() == ItemEvent.DESELECTED) {
                if (edge == selectedPCInterface) {
                    setNewSelectedParameterControlInterface(null);
                }
            }
        }
    });

    this.addComponentListener(new ComponentListener() {
        @Override
        public void componentShown(ComponentEvent e) {
        }

        @Override
        public void componentResized(ComponentEvent e) {
            graphViewer.getGraphLayout().setSize(graphViewer.getSize());
        }

        @Override
        public void componentMoved(ComponentEvent e) {
        }

        @Override
        public void componentHidden(ComponentEvent e) {
        }
    });

    ///////////// Side panel (parameter control)
    pcInterfacePanel.setPreferredSize(new Dimension(200, 0));
    pcInterfacePanel.setLayout(new BorderLayout());

    pcInterfacePanelContents.setLayout(new GridLayout(0, 2, 0, 5));
    pcInterfacePanel.add(pcInterfacePanelContents, BorderLayout.NORTH);

    ///////////// [this]

    setLayout(new BorderLayout(10, 10));

    add(graphViewer, BorderLayout.CENTER);
    add(pcInterfacePanel, BorderLayout.EAST);
}

From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositMain.java

private void treeStructMapKeyTyped(java.awt.event.KeyEvent evt) {
    if (evt.getKeyChar() == KeyEvent.VK_DELETE) {
        depositPresenter.deleteStructMapItem();
    }
}

From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositMain.java

private void treeEntitiesKeyTyped(java.awt.event.KeyEvent evt) {
    if (evt.getKeyChar() == KeyEvent.VK_DELETE) {
        depositPresenter.deleteEntity();
    } else {/*  w ww .j a  v  a  2 s  . c  o  m*/
        if ((evt.getModifiersEx() & InputEvent.ALT_DOWN_MASK) != 0) {
            if (evt.getKeyChar() == 's') {
                depositPresenter.createAutoStructItem(false);
            } else if (evt.getKeyChar() == 'r') {
                depositPresenter.createAutoStructItem(true);
            }
            processFileSystemKey(evt.getKeyChar());
        }
    }
}

From source file:org.docx4all.swing.text.WordMLEditorKit.java

private void initKeyBindings(JEditorPane editor) {
    ActionMap myActionMap = new ActionMap();
    InputMap myInputMap = new InputMap();

    KeyStroke ks = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.SHIFT_MASK);
    myActionMap.put(insertSoftBreakAction, new InsertSoftBreakAction(insertSoftBreakAction));
    myInputMap.put(ks, insertSoftBreakAction);

    ks = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
    myActionMap.put(enterKeyTypedAction, new EnterKeyTypedAction(enterKeyTypedAction));
    myInputMap.put(ks, enterKeyTypedAction);

    ks = KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0);
    myActionMap.put(deleteNextCharAction, new DeleteNextCharAction(deleteNextCharAction));
    myInputMap.put(ks, deleteNextCharAction);

    ks = KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0);
    myActionMap.put(deletePrevCharAction, new DeletePrevCharAction(deletePrevCharAction));
    myInputMap.put(ks, deletePrevCharAction);

    myActionMap.setParent(editor.getActionMap());
    myInputMap.setParent(editor.getInputMap());
    editor.setActionMap(myActionMap);/* w  ww .j  a  va  2  s  .  c om*/
    editor.setInputMap(JComponent.WHEN_FOCUSED, myInputMap);
}

From source file:org.domainmath.gui.FileTreePanel.java

/**
 * Creates new form FileTreePanel/*  w  ww.j ava  2s  . c  om*/
 * @param frame
 */

public FileTreePanel(MainFrame frame) {
    initComponents();
    this.frame = frame;
    fileTree.setEditable(true);
    addPopupMenuToFileTree();

    ToolTipManager.sharedInstance().registerComponent(fileTree);

    // handle right click event on File Tree.
    fileTree.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent e) {
            if (e.getClickCount() == 2) {
                TreePath path = fileTree.getPathForLocation(e.getX(), e.getY());
                Rectangle pathBounds = fileTree.getUI().getPathBounds(fileTree, path);
                if (pathBounds != null && pathBounds.contains(e.getX(), e.getY())) {
                    File file = (File) fileTree.getLastSelectedPathComponent();
                    selectFile(file);
                }
            }
        }
    });

    keyDeleteItem = KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0);
    keyRenameItem = KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0);
    keyOpenItem = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
    keyRefreshItem = KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0);
}

From source file:org.interreg.docexplore.management.manage.ManageComponent.java

@SuppressWarnings("serial")
public ManageComponent(MainWindow win, final ManageHandler handler, boolean editable, boolean showPages) {
    super(new BorderLayout());

    this.win = win;
    this.handler = handler;
    this.bookList = new JList(new CollectionNode(this));
    setBorder(BorderFactory.createLineBorder(Color.black, 1));

    bookList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    bookList.setCellRenderer(new ManageCellRenderer());
    //tree.setRowHeight(52);
    add(new JScrollPane(bookList), BorderLayout.CENTER);

    if (editable) {
        bookList.addMouseListener(new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
                if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2) {
                    int index = bookList.locationToIndex(e.getPoint());
                    if (index < 0 || !bookList.getCellBounds(index, index).contains(e.getPoint()))
                        return;
                    handler.bookOpened((Book) bookList.getModel().getElementAt(index));
                }//w  w  w  . ja va  2s .c  om
            }
        });
        this.toolbar = new ManageToolbar(this);
        add(toolbar, BorderLayout.NORTH);

        bookList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
            public void valueChanged(ListSelectionEvent e) {
                if (e.getValueIsAdjusting())
                    return;
                int count = bookList.getSelectedIndices().length;
                toolbar.deleteButton.setEnabled(count > 0);
                toolbar.editButton.setEnabled(count == 1);
                //            toolbar.processButton.setEnabled(count == 1);
                toolbar.exportButton.setEnabled(count == 1);
            }
        });
    }
    bookList.setBackground(new JPanel().getBackground());

    getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
            .put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "DEL");
    getActionMap().put("DEL", new AbstractAction() {
        public void actionPerformed(ActionEvent arg0) {
            @SuppressWarnings({ "unchecked", "rawtypes" })
            Vector<Book> books = new Vector(Arrays.asList(bookList.getSelectedValues()));
            if (books.size() > 0 && handler.booksDeleted(books)) {
                ((CollectionNode) bookList.getModel()).reload();
                bookList.clearSelection();
                bookList.repaint();
            }
        }
    });
}

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();// ww  w .ja  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();
}