List of usage examples for java.awt.event KeyEvent getKeyCode
public int getKeyCode()
From source file:base.BasePlayer.BedCanvas.java
@Override public void keyPressed(KeyEvent e) { // TODO Auto-generated method stub int keyCode = e.getKeyCode(); if (keyCode == KeyEvent.VK_PLUS || keyCode == 107) { heightchanged = true;// ww w .j a v a2s .com for (int i = 0; i < bedTrack.size(); i++) { if (bedTrack.get(i).nodeHeight < 20) { bedTrack.get(i).nodeHeight++; } } repaint(); } if (keyCode == KeyEvent.VK_MINUS || keyCode == 109) { heightchanged = true; for (int i = 0; i < bedTrack.size(); i++) { if (bedTrack.get(i).nodeHeight > 1) { bedTrack.get(i).nodeHeight--; } } repaint(); } if (keyCode == KeyEvent.VK_PAGE_UP) { if (this.forwardColor.getAlpha() < 255) { this.forwardColor = new Color(this.forwardColor.getRed(), this.forwardColor.getGreen(), this.forwardColor.getBlue(), this.forwardColor.getAlpha() + 15); this.reverseColor = new Color(this.reverseColor.getRed(), this.reverseColor.getGreen(), this.reverseColor.getBlue(), this.reverseColor.getAlpha() + 15); for (int i = 0; i < bedTrack.size(); i++) { if (bedTrack.get(i).getColors().size() > 0) { Iterator<Map.Entry<Integer, Color>> it; Map.Entry<Integer, Color> pair; Color color; it = bedTrack.get(i).getColors().entrySet().iterator(); while (it.hasNext()) { pair = (Map.Entry<Integer, Color>) it.next(); color = pair.getValue(); color = new Color(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha() + 15); bedTrack.get(i).getColors().put(pair.getKey(), color); } } } } repaint(); } if (keyCode == KeyEvent.VK_PAGE_DOWN) { if (this.forwardColor.getAlpha() > 0) { this.forwardColor = new Color(this.forwardColor.getRed(), this.forwardColor.getGreen(), this.forwardColor.getBlue(), this.forwardColor.getAlpha() - 15); this.reverseColor = new Color(this.reverseColor.getRed(), this.reverseColor.getGreen(), this.reverseColor.getBlue(), this.reverseColor.getAlpha() - 15); for (int i = 0; i < bedTrack.size(); i++) { if (bedTrack.get(i).getColors().size() > 0) { Iterator<Map.Entry<Integer, Color>> it; Map.Entry<Integer, Color> pair; Color color; it = bedTrack.get(i).getColors().entrySet().iterator(); while (it.hasNext()) { pair = (Map.Entry<Integer, Color>) it.next(); color = pair.getValue(); color = new Color(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha() - 15); bedTrack.get(i).getColors().put(pair.getKey(), color); } } } } repaint(); } }
From source file:org.signserver.admin.gui.MainView.java
private void auditLogTableKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_auditLogTableKeyReleased if (evt.getKeyCode() == KeyEvent.VK_ENTER) { displayLogEntryAction();//from w w w. j a v a 2 s . co m } }
From source file:org.yccheok.jstock.gui.MainFrame.java
private void jTable1KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTable1KeyPressed if (KeyEvent.VK_DELETE == evt.getKeyCode()) { this.deteleSelectedTableRow(); return;//from w w w .j ava 2 s.co m } if (evt.isActionKey()) { int[] rows = MainFrame.this.jTable1.getSelectedRows(); if (rows.length == 1) { int row = rows[0]; final StockTableModel tableModel = (StockTableModel) jTable1.getModel(); final int modelIndex = jTable1.convertRowIndexToModel(row); final Stock stock = tableModel.getStock(modelIndex); this.updateDynamicChart(stock); } else { this.updateDynamicChart(null); } } }
From source file:library.Form_Library.java
License:asdf
private void formKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_formKeyPressed if (evt.getKeyCode() == KeyEvent.VK_F5) { System.out.println("hello f4"); }//from w w w. j a va 2s . co m }
From source file:library.Form_Library.java
License:asdf
private void jPanel3KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jPanel3KeyPressed if (evt.getKeyCode() == KeyEvent.VK_F5) { System.out.println("hello f4"); }//from w ww .j av a 2 s . c o m }
From source file:library.Form_Library.java
License:asdf
private void jPanel1KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jPanel1KeyPressed if (evt.getKeyCode() == KeyEvent.VK_F5) { System.out.println("hello f4"); }//from ww w . j a v a 2 s .c o m }
From source file:org.yccheok.jstock.gui.JStock.java
private void jTable1KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTable1KeyPressed if (KeyEvent.VK_DELETE == evt.getKeyCode()) { this.deteleSelectedTableRow(); return;//from w w w .j a v a2 s . c om } else if (KeyEvent.VK_ENTER == evt.getKeyCode()) { displayHistoryCharts(); return; } else if (evt.isActionKey()) { int[] rows = JStock.this.jTable1.getSelectedRows(); if (rows.length == 1) { int row = rows[0]; final StockTableModel tableModel = (StockTableModel) jTable1.getModel(); final int modelIndex = jTable1.convertRowIndexToModel(row); final Stock stock = tableModel.getStock(modelIndex); this.updateDynamicChart(stock); } else { this.updateDynamicChart(null); } } }
From source file:org.forester.archaeopteryx.TreePanel.java
final private void keyPressedCalls(final KeyEvent e) { if (isOvOn() && (getMousePosition() != null) && (getMousePosition().getLocation() != null)) { if (inOvVirtualRectangle(getMousePosition().x, getMousePosition().y)) { if (!isInOvRect()) { setInOvRect(true);// w w w . j a v a 2s . c o m } } else if (isInOvRect()) { setInOvRect(false); } } if (e.getModifiersEx() == InputEvent.CTRL_DOWN_MASK) { if ((e.getKeyCode() == KeyEvent.VK_DELETE) || (e.getKeyCode() == KeyEvent.VK_HOME) || (e.getKeyCode() == KeyEvent.VK_F)) { getMainPanel().getTreeFontSet().mediumFonts(); getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged(true); } else if ((e.getKeyCode() == KeyEvent.VK_SUBTRACT) || (e.getKeyCode() == KeyEvent.VK_MINUS)) { getMainPanel().getTreeFontSet().decreaseFontSize(); getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged(true); } else if (plusPressed(e.getKeyCode())) { getMainPanel().getTreeFontSet().increaseFontSize(); getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged(true); } } else { if ((e.getKeyCode() == KeyEvent.VK_DELETE) || (e.getKeyCode() == KeyEvent.VK_HOME) || (e.getKeyCode() == KeyEvent.VK_F)) { getControlPanel().showWhole(); } else if ((e.getKeyCode() == KeyEvent.VK_UP) || (e.getKeyCode() == KeyEvent.VK_DOWN) || (e.getKeyCode() == KeyEvent.VK_LEFT) || (e.getKeyCode() == KeyEvent.VK_RIGHT)) { if (e.getModifiersEx() == InputEvent.SHIFT_DOWN_MASK) { if (e.getKeyCode() == KeyEvent.VK_UP) { getMainPanel().getControlPanel().zoomInY(Constants.WHEEL_ZOOM_IN_FACTOR); getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged(false); } else if (e.getKeyCode() == KeyEvent.VK_DOWN) { getMainPanel().getControlPanel().zoomOutY(Constants.WHEEL_ZOOM_OUT_FACTOR); getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged(false); } else if (e.getKeyCode() == KeyEvent.VK_LEFT) { getMainPanel().getControlPanel().zoomOutX(Constants.WHEEL_ZOOM_OUT_FACTOR, Constants.WHEEL_ZOOM_OUT_X_CORRECTION_FACTOR); getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged(false); } else if (e.getKeyCode() == KeyEvent.VK_RIGHT) { getMainPanel().getControlPanel().zoomInX(Constants.WHEEL_ZOOM_IN_FACTOR, Constants.WHEEL_ZOOM_IN_FACTOR); getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged(false); } } else { final int d = 80; int dx = 0; int dy = -d; if (e.getKeyCode() == KeyEvent.VK_DOWN) { dy = d; } else if (e.getKeyCode() == KeyEvent.VK_LEFT) { dx = -d; dy = 0; } else if (e.getKeyCode() == KeyEvent.VK_RIGHT) { dx = d; dy = 0; } final Point scroll_position = getMainPanel().getCurrentScrollPane().getViewport() .getViewPosition(); scroll_position.x = scroll_position.x + dx; scroll_position.y = scroll_position.y + dy; if (scroll_position.x <= 0) { scroll_position.x = 0; } else { final int max_x = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar() .getMaximum() - getMainPanel().getCurrentScrollPane().getHorizontalScrollBar().getVisibleAmount(); if (scroll_position.x >= max_x) { scroll_position.x = max_x; } } if (scroll_position.y <= 0) { scroll_position.y = 0; } else { final int max_y = getMainPanel().getCurrentScrollPane().getVerticalScrollBar().getMaximum() - getMainPanel().getCurrentScrollPane().getVerticalScrollBar().getVisibleAmount(); if (scroll_position.y >= max_y) { scroll_position.y = max_y; } } repaint(); getMainPanel().getCurrentScrollPane().getViewport().setViewPosition(scroll_position); } } else if ((e.getKeyCode() == KeyEvent.VK_SUBTRACT) || (e.getKeyCode() == KeyEvent.VK_MINUS)) { getMainPanel().getControlPanel().zoomOutY(Constants.WHEEL_ZOOM_OUT_FACTOR); getMainPanel().getControlPanel().zoomOutX(Constants.WHEEL_ZOOM_OUT_FACTOR, Constants.WHEEL_ZOOM_OUT_X_CORRECTION_FACTOR); getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged(false); } else if (plusPressed(e.getKeyCode())) { getMainPanel().getControlPanel().zoomInX(Constants.WHEEL_ZOOM_IN_FACTOR, Constants.WHEEL_ZOOM_IN_FACTOR); getMainPanel().getControlPanel().zoomInY(Constants.WHEEL_ZOOM_IN_FACTOR); getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged(false); } else if (e.getKeyCode() == KeyEvent.VK_S) { if ((getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED) || (getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR)) { setStartingAngle((getStartingAngle() % TWO_PI) + ANGLE_ROTATION_UNIT); getControlPanel().displayedPhylogenyMightHaveChanged(false); } } else if (e.getKeyCode() == KeyEvent.VK_A) { if ((getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED) || (getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR)) { setStartingAngle((getStartingAngle() % TWO_PI) - ANGLE_ROTATION_UNIT); if (getStartingAngle() < 0) { setStartingAngle(TWO_PI + getStartingAngle()); } getControlPanel().displayedPhylogenyMightHaveChanged(false); } } else if (e.getKeyCode() == KeyEvent.VK_D) { boolean selected = false; if (getOptions().getNodeLabelDirection() == NODE_LABEL_DIRECTION.HORIZONTAL) { getOptions().setNodeLabelDirection(NODE_LABEL_DIRECTION.RADIAL); selected = true; } else { getOptions().setNodeLabelDirection(NODE_LABEL_DIRECTION.HORIZONTAL); } if (getMainPanel().getMainFrame() == null) { // Must be "E" applet version. final ArchaeopteryxE ae = (ArchaeopteryxE) ((MainPanelApplets) getMainPanel()).getApplet(); if (ae.getlabelDirectionCbmi() != null) { ae.getlabelDirectionCbmi().setSelected(selected); } } else { getMainPanel().getMainFrame().getlabelDirectionCbmi().setSelected(selected); } repaint(); } else if (e.getKeyCode() == KeyEvent.VK_X) { switchDisplaygetPhylogenyGraphicsType(); repaint(); } else if (e.getKeyCode() == KeyEvent.VK_C) { cycleColors(); repaint(); } else if (getOptions().isShowOverview() && isOvOn() && (e.getKeyCode() == KeyEvent.VK_O)) { MainFrame.cycleOverview(getOptions(), this); repaint(); } else if (getOptions().isShowOverview() && isOvOn() && (e.getKeyCode() == KeyEvent.VK_I)) { increaseOvSize(); } else if (getOptions().isShowOverview() && isOvOn() && (e.getKeyCode() == KeyEvent.VK_U)) { decreaseOvSize(); } e.consume(); } }
From source file:edu.ku.brc.specify.tasks.subpane.wb.wbuploader.Uploader.java
public void keyPressed(KeyEvent e) { logDebug("keyPressed"); int key = e.getKeyCode(); if (key == KeyEvent.VK_ENTER || key == KeyEvent.VK_TAB || key == KeyEvent.VK_DOWN || key == KeyEvent.VK_UP || (key == KeyEvent.VK_TAB && e.isShiftDown()) || key == KeyEvent.VK_HOME || key == KeyEvent.VK_END) { editInvalidCell(e);/*from w ww . j a v a 2 s .co m*/ e.consume(); } }
From source file:edu.ku.brc.specify.tasks.subpane.wb.wbuploader.Uploader.java
/** * @param e/* ww w .ja v a 2s. c o m*/ * * Moves to WB cell for appropriate InvalidValue and starts editing it. */ protected void editInvalidCell(KeyEvent e) { logDebug("editing invalid cell"); int key = e.getKeyCode(); if (key == KeyEvent.VK_ENTER || key == KeyEvent.VK_TAB || key == KeyEvent.VK_DOWN) goToNextInvalidCell(); else if (key == KeyEvent.VK_UP || (key == KeyEvent.VK_TAB && e.isShiftDown())) goToPrevInvalidCell(); else if (key == KeyEvent.VK_HOME) goToFirstInvalidCell(); else if (key == KeyEvent.VK_END) goToLastInvalidCell(); }