Java Code Examples for java.awt.event.ActionEvent#getModifiers()
The following examples show how to use
java.awt.event.ActionEvent#getModifiers() .
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: constellation File: ResetViewAction.java License: Apache License 2.0 | 6 votes |
@Override public void actionPerformed(final ActionEvent e) { final boolean isCtrl = (e.getModifiers() & InputEvent.CTRL_DOWN_MASK) != 0; final boolean isShift = (e.getModifiers() & InputEvent.SHIFT_DOWN_MASK) != 0; final String axis; final boolean negative; if (isShift && !isCtrl) { axis = "x"; negative = false; } else if (isCtrl && !isShift) { axis = "y"; negative = true; } else { axis = "z"; negative = false; } final Graph graph = context.getGraph(); PluginExecution.withPlugin(InteractiveGraphPluginRegistry.RESET_VIEW) .withParameter(ResetViewPlugin.AXIS_PARAMETER_ID, axis) .withParameter(ResetViewPlugin.NEGATIVE_PARAMETER_ID, negative) .withParameter(ResetViewPlugin.SIGNIFICANT_PARAMETER_ID, true) .executeLater(graph); }
Example 2
Source Project: jdk8u-dev-jdk File: DefaultEditorKit.java License: GNU General Public License v2.0 | 6 votes |
/** * The operation to perform when this action is triggered. * * @param e the action event */ public void actionPerformed(ActionEvent e) { JTextComponent target = getTextComponent(e); if ((target != null) && (e != null)) { if ((! target.isEditable()) || (! target.isEnabled())) { return; } String content = e.getActionCommand(); int mod = e.getModifiers(); if ((content != null) && (content.length() > 0)) { boolean isPrintableMask = true; Toolkit tk = Toolkit.getDefaultToolkit(); if (tk instanceof SunToolkit) { isPrintableMask = ((SunToolkit)tk).isPrintableCharacterModifiersMask(mod); } if (isPrintableMask) { char c = content.charAt(0); if ((c >= 0x20) && (c != 0x7F)) { target.replaceSelection(content); } } } } }
Example 3
Source Project: Bytecoder File: DefaultEditorKit.java License: Apache License 2.0 | 6 votes |
/** * The operation to perform when this action is triggered. * * @param e the action event */ public void actionPerformed(ActionEvent e) { JTextComponent target = getTextComponent(e); if ((target != null) && (e != null)) { if ((! target.isEditable()) || (! target.isEnabled())) { return; } String content = e.getActionCommand(); int mod = e.getModifiers(); if ((content != null) && (content.length() > 0)) { boolean isPrintableMask = true; Toolkit tk = Toolkit.getDefaultToolkit(); if (tk instanceof SunToolkit) { isPrintableMask = ((SunToolkit)tk).isPrintableCharacterModifiersMask(mod); } char c = content.charAt(0); if ((isPrintableMask && (c >= 0x20) && (c != 0x7F)) || (!isPrintableMask && (c >= 0x200C) && (c <= 0x200D))) { target.replaceSelection(content); } } } }
Example 4
Source Project: TencentKona-8 File: DefaultEditorKit.java License: GNU General Public License v2.0 | 6 votes |
/** * The operation to perform when this action is triggered. * * @param e the action event */ public void actionPerformed(ActionEvent e) { JTextComponent target = getTextComponent(e); if ((target != null) && (e != null)) { if ((! target.isEditable()) || (! target.isEnabled())) { return; } String content = e.getActionCommand(); int mod = e.getModifiers(); if ((content != null) && (content.length() > 0)) { boolean isPrintableMask = true; Toolkit tk = Toolkit.getDefaultToolkit(); if (tk instanceof SunToolkit) { isPrintableMask = ((SunToolkit)tk).isPrintableCharacterModifiersMask(mod); } char c = content.charAt(0); if ((isPrintableMask && (c >= 0x20) && (c != 0x7F)) || (!isPrintableMask && (c >= 0x200C) && (c <= 0x200D))) { target.replaceSelection(content); } } } }
Example 5
Source Project: java-swing-tips File: MainPanel.java License: MIT License | 6 votes |
@Override public void actionPerformed(ActionEvent e) { if (table.isEditing()) { table.getCellEditor().stopCellEditing(); } int[] pos = table.getSelectedRows(); if (pos.length == 0) { return; } RowDataModel model = (RowDataModel) table.getModel(); boolean isShiftDown = (e.getModifiers() & ActionEvent.SHIFT_MASK) != 0; if (isShiftDown) { // Jump to the end model.moveRow(pos[0], pos[pos.length - 1], model.getRowCount() - pos.length); table.setRowSelectionInterval(model.getRowCount() - pos.length, model.getRowCount() - 1); } else { if (pos[pos.length - 1] == model.getRowCount() - 1) { return; } model.moveRow(pos[0], pos[pos.length - 1], pos[0] + 1); table.setRowSelectionInterval(pos[0] + 1, pos[pos.length - 1] + 1); } Rectangle r = table.getCellRect(model.getRowCount() - 1, 0, true); table.scrollRectToVisible(r); }
Example 6
Source Project: ganttproject File: GPAction.java License: GNU General Public License v3.0 | 6 votes |
protected boolean calledFromAppleScreenMenu(ActionEvent e) { if (e == null) { return false; } if (String.valueOf(e.getSource()).indexOf("JMenu") == -1) { return false; } if (e.getModifiers() == 0) { return false; } StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace(); for (int i = 0; i < Math.min(10, stackTrace.length); i++) { if (stackTrace[i].getClassName().indexOf("ScreenMenuItem") > 0) { return true; } } return false; }
Example 7
Source Project: jdk8u-jdk File: DefaultEditorKit.java License: GNU General Public License v2.0 | 6 votes |
/** * The operation to perform when this action is triggered. * * @param e the action event */ public void actionPerformed(ActionEvent e) { JTextComponent target = getTextComponent(e); if ((target != null) && (e != null)) { if ((! target.isEditable()) || (! target.isEnabled())) { return; } String content = e.getActionCommand(); int mod = e.getModifiers(); if ((content != null) && (content.length() > 0)) { boolean isPrintableMask = true; Toolkit tk = Toolkit.getDefaultToolkit(); if (tk instanceof SunToolkit) { isPrintableMask = ((SunToolkit)tk).isPrintableCharacterModifiersMask(mod); } if (isPrintableMask) { char c = content.charAt(0); if ((c >= 0x20) && (c != 0x7F)) { target.replaceSelection(content); } } } } }
Example 8
Source Project: gate-core File: AnnotationEditor.java License: GNU Lesser General Public License v3.0 | 6 votes |
@Override public void actionPerformed(ActionEvent evt) { int increment = 1; if((evt.getModifiers() & ActionEvent.SHIFT_MASK) != 0) { // CTRL pressed -> use tokens for advancing increment = SHIFT_INCREMENT; if((evt.getModifiers() & ActionEvent.CTRL_MASK) != 0) { increment = CTRL_SHIFT_INCREMENT; } } long newValue = ann.getStartNode().getOffset().longValue() - increment; if(newValue < 0) newValue = 0; try { moveAnnotation(set, ann, new Long(newValue), ann.getEndNode() .getOffset()); } catch(InvalidOffsetException ioe) { throw new GateRuntimeException(ioe); } }
Example 9
Source Project: java-swing-tips File: MainPanel.java License: MIT License | 6 votes |
@Override public void actionPerformed(ActionEvent e) { if (table.isEditing()) { table.getCellEditor().stopCellEditing(); } int[] pos = table.getSelectedRows(); if (pos.length == 0) { return; } RowDataModel model = (RowDataModel) table.getModel(); boolean isShiftDown = (e.getModifiers() & ActionEvent.SHIFT_MASK) != 0; System.out.println(isShiftDown); if (isShiftDown) { // Jump to the top model.moveRow(pos[0], pos[pos.length - 1], 0); table.setRowSelectionInterval(0, pos.length - 1); } else { if (pos[0] == 0) { return; } model.moveRow(pos[0], pos[pos.length - 1], pos[0] - 1); table.setRowSelectionInterval(pos[0] - 1, pos[pos.length - 1] - 1); } Rectangle r = table.getCellRect(model.getRowCount() - 1, 0, true); table.scrollRectToVisible(r); }
Example 10
Source Project: openjdk-jdk8u-backup File: DefaultEditorKit.java License: GNU General Public License v2.0 | 6 votes |
/** * The operation to perform when this action is triggered. * * @param e the action event */ public void actionPerformed(ActionEvent e) { JTextComponent target = getTextComponent(e); if ((target != null) && (e != null)) { if ((! target.isEditable()) || (! target.isEnabled())) { return; } String content = e.getActionCommand(); int mod = e.getModifiers(); if ((content != null) && (content.length() > 0)) { boolean isPrintableMask = true; Toolkit tk = Toolkit.getDefaultToolkit(); if (tk instanceof SunToolkit) { isPrintableMask = ((SunToolkit)tk).isPrintableCharacterModifiersMask(mod); } if (isPrintableMask) { char c = content.charAt(0); if ((c >= 0x20) && (c != 0x7F)) { target.replaceSelection(content); } } } } }
Example 11
Source Project: egdownloader File: HTMLDocumentEditor.java License: GNU General Public License v2.0 | 5 votes |
public void actionPerformed(ActionEvent ae) { String actionCommand = ae.getActionCommand(); if (debug) { int modifier = ae.getModifiers(); long when = ae.getWhen(); String parameter = ae.paramString(); System.out.println("actionCommand: " + actionCommand); System.out.println("modifier: " + modifier); System.out.println("when: " + when); System.out.println("parameter: " + parameter); } if (actionCommand.compareTo("New") == 0) { startNewDocument(); } else if (actionCommand.compareTo("Open") == 0) { openDocument(); } else if (actionCommand.compareTo("Save") == 0) { saveDocument(); } else if (actionCommand.compareTo("Save As") == 0) { saveDocumentAs(); } else if (actionCommand.compareTo("Exit") == 0) { exit(); } else if (actionCommand.compareTo("Clear") == 0) { clear(); } else if (actionCommand.compareTo("Select All") == 0) { selectAll(); } else if (actionCommand.compareTo("帮助") == 0) { help(); } else if (actionCommand.compareTo("Keyboard Shortcuts") == 0) { showShortcuts(); } else if (actionCommand.compareTo("About QuantumHyperSpace") == 0) { aboutQuantumHyperSpace(); } }
Example 12
Source Project: tda File: PopupMenu.java License: GNU Lesser General Public License v2.1 | 5 votes |
public void actionPerformed(ActionEvent e) { if(e.getSource() instanceof JMenuItem) { JMenuItem source = (JMenuItem) (e.getSource()); if (source.getText().equals("Goto Line...")) { gotoLine(); } else if (source.getText().equals("Search...")) { search(); } else if (source.getText().startsWith("Search again")) { search(searchString, ref.getCaretPosition() + 1); } else if (source.getText().startsWith("Copy to Clipboard")) { ref.copy(); } else if (source.getText().startsWith("Select All")) { ref.selectAll(); } else if (source.getText().startsWith("Select None")) { ref.selectNone(); } else if (source.getText().startsWith("Save Logfile...")) { parent.saveLogFile(); } } else if(e.getSource() instanceof JEditTextArea) { // only one key binding if (e.getModifiers() > 0) { if(ref.getSelectionStart() >= 0) { ref.copy(); } } else { if (searchString != null) { search(searchString, ref.getCaretPosition() + 1); } } } }
Example 13
Source Project: consulo File: IdeErrorsDialog.java License: Apache License 2.0 | 5 votes |
@Override public void actionPerformed(ActionEvent e) { final DataContext dataContext = ((BaseDataManager)DataManager.getInstance()).getDataContextTest((Component)e.getSource()); AnActionEvent event = new AnActionEvent(null, dataContext, ActionPlaces.UNKNOWN, myAnalyze.getTemplatePresentation(), ActionManager.getInstance(), e.getModifiers()); final Project project = dataContext.getData(CommonDataKeys.PROJECT); if (project != null) { myAnalyze.actionPerformed(event); doOKAction(); } }
Example 14
Source Project: jts File: WKTPanel.java License: GNU Lesser General Public License v2.1 | 5 votes |
void copy(ActionEvent e, int geomIndex) { boolean isFormatted = 0 != (e.getModifiers() & ActionEvent.CTRL_MASK); Geometry g = tbModel.getCurrentTestCaseEdit().getGeometry(geomIndex); if (g != null) SwingUtil.copyToClipboard(g, isFormatted); }
Example 15
Source Project: raccoon4 File: FullAppDescriptionBuilder.java License: Apache License 2.0 | 5 votes |
@Override public void actionPerformed(ActionEvent e) { if (e.getSource() == download) { if ((e.getModifiers() & ActionEvent.ALT_MASK) == ActionEvent.ALT_MASK) { System.err.println(current.toString()); return; } globals.get(TransferManager.class).schedule(globals, new AppDownloadWorker(globals, current), TransferManager.WAN); download.setEnabled(false); } }
Example 16
Source Project: netcdf-java File: Field.java License: BSD 3-Clause "New" or "Revised" License | 4 votes |
public void actionPerformed(ActionEvent e) { ActionEvent me = new ActionEvent(Field.this, e.getID(), e.getActionCommand(), e.getWhen(), e.getModifiers()); orgAct.actionPerformed(me); }
Example 17
Source Project: binnavi File: JHexView.java License: Apache License 2.0 | 4 votes |
private void changeBy(final ActionEvent event, final int length) { if (event.getModifiers() == ActionEvent.SHIFT_MASK) { if ((getSelectionStart() + getSelectionLength() + length) < 0) { setSelectionLength(-getSelectionStart()); } else { if ((getSelectionStart() + getSelectionLength() + length) < (2 * m_dataProvider .getDataLength())) { setSelectionLength(getSelectionLength() + length); } else { setSelectionLength((2 * m_dataProvider.getDataLength()) - getSelectionStart()); } } } else { if ((getSelectionStart() + getSelectionLength() + length) < 0) { setSelectionStart(0); } else if ((getSelectionStart() + getSelectionLength() + length) < (2 * m_dataProvider .getDataLength())) { setSelectionStart(getSelectionStart() + getSelectionLength() + length); } else { setSelectionStart(2 * m_dataProvider.getDataLength()); } setSelectionLength(0); } final long newPosition = getSelectionStart() + getSelectionLength(); if (newPosition < (2 * getFirstVisibleByte())) { scrollToPosition(newPosition); } else if (newPosition >= (2 * (getFirstVisibleByte() + getMaximumVisibleBytes()))) { final long invisibleNibbles = newPosition - (2 * (getFirstVisibleByte() + getMaximumVisibleBytes())); final long scrollpos = (2 * getFirstVisibleByte()) + (2 * m_bytesPerRow) + invisibleNibbles; scrollToPosition(scrollpos); } m_caret.setVisible(true); repaint(); }
Example 18
Source Project: Pixelitor File: AddNewLayerAction.java License: GNU General Public License v3.0 | 4 votes |
@Override public void actionPerformed(ActionEvent e) { var comp = OpenImages.getActiveComp(); boolean addBellowActive = (e.getModifiers() & CTRL_MASK) == CTRL_MASK; comp.addNewEmptyLayer(comp.generateNewLayerName(), addBellowActive); }
Example 19
Source Project: jts File: InspectorPanel.java License: GNU Lesser General Public License v2.1 | 4 votes |
private void btnCopy_actionPerformed(ActionEvent e) { boolean isFormatted = 0 != (e.getModifiers() & ActionEvent.CTRL_MASK); Geometry geom = geomTreePanel.getSelectedGeometry(); if (geom == null) return; SwingUtil.copyToClipboard(geom, isFormatted); }
Example 20
Source Project: visualvm File: NodeObjectsView.java License: GNU General Public License v2.0 | 4 votes |
public boolean isMiddleButtonDefault(ActionEvent e) { return (e.getModifiers() & ActionEvent.CTRL_MASK) != ActionEvent.CTRL_MASK; }