Example usage for java.awt.event KeyEvent VK_ENTER

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

Introduction

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

Prototype

int VK_ENTER

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

Click Source Link

Document

Constant for the ENTER virtual key.

Usage

From source file:com.osparking.osparking.Settings_System.java

private void makeEnterActAsTab() {
    KeyStroke enter = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
    KeyStroke tab = KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0);
    KeyStroke ctrlTab = KeyStroke.getKeyStroke(KeyEvent.VK_TAB, KeyEvent.CTRL_DOWN_MASK);
    Set<KeyStroke> keys = new HashSet<>();
    keys.add(enter);/*  w w  w  . j  a  va  2 s . c o m*/
    keys.add(tab);
    keys.add(ctrlTab);
    KeyboardFocusManager.getCurrentKeyboardFocusManager()
            .setDefaultFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, keys);
}

From source file:base.BasePlayer.Main.java

@Override

public void keyPressed(KeyEvent e) {
    keyCode = e.getKeyCode();/*w ww  .  j  a  va2s .  c  o  m*/

    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());

        }

    }

}