Java Code Examples for java.awt.event.KeyEvent#VK_CONTEXT_MENU

The following examples show how to use java.awt.event.KeyEvent#VK_CONTEXT_MENU . 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 File: ExplorerComponent.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
public void keyPressed(KeyEvent e) {
    if ((e.getKeyCode() == KeyEvent.VK_CONTEXT_MENU)
                    || ((e.getKeyCode() == KeyEvent.VK_F10) && (e.getModifiers() == InputEvent.SHIFT_MASK))) {
        
        e.consume();
        
        int x;
        int y;
        TreePath path = explorerTree.getSelectionPath();
        
        if (path != null) {
            Rectangle pathRect = explorerTree.getPathBounds(path);
            x = pathRect.x;
            y = pathRect.y;
        } else {
            Point pathPoint = new Point(explorerTree.getWidth() / 3, explorerTree.getHeight() / 3);
            x = pathPoint.x;
            y = pathPoint.y;
        }
        
        displayContextMenu(x, y);
    }
}
 
Example 2
Source File: PopupMenuAction.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public State keyPressed (Widget widget, WidgetKeyEvent event) {
        if (event.getKeyCode () == KeyEvent.VK_CONTEXT_MENU  ||  ((event.getModifiers () & InputEvent.SHIFT_MASK) == InputEvent.SHIFT_MASK  &&  event.getKeyCode () == KeyEvent.VK_F10)) {
            JPopupMenu popupMenu = provider.getPopupMenu (widget, null);
            if (popupMenu != null) {
                JComponent view = widget.getScene ().getView ();
                if (view != null) {
//                    Rectangle visibleRect = view.getVisibleRect ();
//                    popupMenu.show (view, visibleRect.x + 10, visibleRect.y + 10);
                    Rectangle bounds = widget.getBounds ();
                    Point location = new Point (bounds.x + 5, bounds.y + 5);
                    location = widget.convertLocalToScene (location);
                    location = widget.getScene ().convertSceneToView (location);
                    popupMenu.show (view, location.x, location.y);
                }
            }
            return State.CONSUMED;
        }
        return State.REJECTED;
    }
 
Example 3
Source File: LinkButton.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
protected void processKeyEvent(KeyEvent e) {
    int code = e.getKeyCode();
    if (code == KeyEvent.VK_CONTEXT_MENU ||
       (code == KeyEvent.VK_F10 && e.getModifiers() == InputEvent.SHIFT_MASK)) {
        e.consume();
        showPopupMenu(null);
    }
    
    super.processKeyEvent(e);
}
 
Example 4
Source File: AbstractPopupListener.java    From wpcleaner with Apache License 2.0 5 votes vote down vote up
/**
 * Check conditions for displaying a popup menu in response to a key event.
 * 
 * @param e Event.
 */
private void maybeShowPopup(KeyEvent e) {
  if (e == null) {
    return;
  }
  if (e.getKeyCode() != KeyEvent.VK_CONTEXT_MENU) {
    return;
  }
  showPopup(e);
}
 
Example 5
Source File: HTMLTextArea.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
protected void processKeyEvent(KeyEvent e) {
    int code = e.getKeyCode();
    if (code == KeyEvent.VK_CONTEXT_MENU ||
       (code == KeyEvent.VK_F10 && e.getModifiers() == InputEvent.SHIFT_MASK)) {
        e.consume();
        showPopupMenu(null);
    }
    
    super.processKeyEvent(e);
}
 
Example 6
Source File: ProfilerTable.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
protected void processKeyEvent(KeyEvent e) {
    int code = e.getKeyCode();
    if (code == KeyEvent.VK_CONTEXT_MENU ||
       (code == KeyEvent.VK_F10 && e.getModifiers() == InputEvent.SHIFT_MASK)) {
        e.consume();
        showPopupMenu(null);
    }
    
    super.processKeyEvent(e);
}
 
Example 7
Source File: InstancesListControllerUI.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
public void keyPressed(KeyEvent e) {
    if ((e.getKeyCode() == KeyEvent.VK_CONTEXT_MENU)
            || ((e.getKeyCode() == KeyEvent.VK_F10) && (e.getModifiers() == InputEvent.SHIFT_MASK))) {
        int selectedRow = instancesListTable.getSelectedRow();

        if (selectedRow != -1) {
            Rectangle rowBounds = instancesListTable.getCellRect(selectedRow, 0, true);
            showTablePopup(instancesListTable, rowBounds.x + (rowBounds.width / 2), rowBounds.y + (rowBounds.height / 2));
        }
    } else if (KeyStroke.getAWTKeyStroke(e.getKeyCode(), e.getModifiers()).equals(COPY_ID_KEYSTROKE)) {
        copyIdToClipboard();
    }
}
 
Example 8
Source File: ClassesListControllerUI.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
public void keyPressed(KeyEvent e) {
    if ((e.getKeyCode() == KeyEvent.VK_CONTEXT_MENU)
            || ((e.getKeyCode() == KeyEvent.VK_F10) && (e.getModifiers() == InputEvent.SHIFT_MASK))) {
        int selectedRow = classesListTable.getSelectedRow();

        if (selectedRow != -1) {
            Rectangle rowBounds = classesListTable.getCellRect(selectedRow, 0, true);
            showPopupMenu(selectedRow, rowBounds.x + (rowBounds.width / 2), rowBounds.y + (rowBounds.height / 2));
        }
    }
}
 
Example 9
Source File: ReferencesBrowserControllerUI.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
public void keyPressed(KeyEvent e) {
    if ((e.getKeyCode() == KeyEvent.VK_CONTEXT_MENU)
            || ((e.getKeyCode() == KeyEvent.VK_F10) && (e.getModifiers() == InputEvent.SHIFT_MASK))) {
        int selectedRow = fieldsListTable.getSelectedRow();

        if (selectedRow != -1) {
            showPopupMenu(selectedRow, -1, -1);
        }
    }
}
 
Example 10
Source File: FieldsBrowserControllerUI.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
public void keyPressed(KeyEvent e) {
    if ((e.getKeyCode() == KeyEvent.VK_CONTEXT_MENU)
            || ((e.getKeyCode() == KeyEvent.VK_F10) && (e.getModifiers() == InputEvent.SHIFT_MASK))) {
        int selectedRow = fieldsListTable.getSelectedRow();

        if (selectedRow != -1) {
            showPopupMenu(selectedRow, -1, -1);
        }
    }
}
 
Example 11
Source File: LinkButton.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
protected void processKeyEvent(KeyEvent e) {
    int code = e.getKeyCode();
    if (code == KeyEvent.VK_CONTEXT_MENU ||
       (code == KeyEvent.VK_F10 && e.getModifiers() == InputEvent.SHIFT_MASK)) {
        e.consume();
        showPopupMenu(null);
    }
    
    super.processKeyEvent(e);
}
 
Example 12
Source File: HTMLTextArea.java    From netbeans with Apache License 2.0 5 votes vote down vote up
protected void processKeyEvent(KeyEvent e) {
    int code = e.getKeyCode();
    if (code == KeyEvent.VK_CONTEXT_MENU ||
       (code == KeyEvent.VK_F10 && e.getModifiers() == InputEvent.SHIFT_MASK)) {
        e.consume();
        showPopupMenu(null);
    }
    
    super.processKeyEvent(e);
}
 
Example 13
Source File: ProfilerTable.java    From netbeans with Apache License 2.0 5 votes vote down vote up
protected void processKeyEvent(KeyEvent e) {
    int code = e.getKeyCode();
    if (code == KeyEvent.VK_CONTEXT_MENU ||
       (code == KeyEvent.VK_F10 && e.getModifiers() == InputEvent.SHIFT_MASK)) {
        e.consume();
        showPopupMenu(null);
    }
    
    super.processKeyEvent(e);
}
 
Example 14
Source File: InstancesListControllerUI.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void keyPressed(KeyEvent e) {
    if ((e.getKeyCode() == KeyEvent.VK_CONTEXT_MENU)
            || ((e.getKeyCode() == KeyEvent.VK_F10) && (e.getModifiers() == InputEvent.SHIFT_MASK))) {
        int selectedRow = instancesListTable.getSelectedRow();

        if (selectedRow != -1) {
            Rectangle rowBounds = instancesListTable.getCellRect(selectedRow, 0, true);
            showTablePopup(instancesListTable, rowBounds.x + (rowBounds.width / 2), rowBounds.y + (rowBounds.height / 2));
        }
    } else if (KeyStroke.getAWTKeyStroke(e.getKeyCode(), e.getModifiers()).equals(COPY_ID_KEYSTROKE)) {
        copyIdToClipboard();
    }
}
 
Example 15
Source File: ClassesListControllerUI.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void keyPressed(KeyEvent e) {
    if ((e.getKeyCode() == KeyEvent.VK_CONTEXT_MENU)
            || ((e.getKeyCode() == KeyEvent.VK_F10) && (e.getModifiers() == InputEvent.SHIFT_MASK))) {
        int selectedRow = classesListTable.getSelectedRow();

        if (selectedRow != -1) {
            Rectangle rowBounds = classesListTable.getCellRect(selectedRow, 0, true);
            showPopupMenu(selectedRow, rowBounds.x + (rowBounds.width / 2), rowBounds.y + (rowBounds.height / 2));
        }
    }
}
 
Example 16
Source File: ReferencesBrowserControllerUI.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void keyPressed(KeyEvent e) {
    if ((e.getKeyCode() == KeyEvent.VK_CONTEXT_MENU)
            || ((e.getKeyCode() == KeyEvent.VK_F10) && (e.getModifiers() == InputEvent.SHIFT_MASK))) {
        int selectedRow = fieldsListTable.getSelectedRow();

        if (selectedRow != -1) {
            showPopupMenu(selectedRow, -1, -1);
        }
    }
}
 
Example 17
Source File: FieldsBrowserControllerUI.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void keyPressed(KeyEvent e) {
    if ((e.getKeyCode() == KeyEvent.VK_CONTEXT_MENU)
            || ((e.getKeyCode() == KeyEvent.VK_F10) && (e.getModifiers() == InputEvent.SHIFT_MASK))) {
        int selectedRow = fieldsListTable.getSelectedRow();

        if (selectedRow != -1) {
            showPopupMenu(selectedRow, -1, -1);
        }
    }
}
 
Example 18
Source File: ProfilingPointsWindowUI.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void keyPressed(KeyEvent e) {
    if ((e.getKeyCode() == KeyEvent.VK_CONTEXT_MENU)
            || ((e.getKeyCode() == KeyEvent.VK_F10) && (e.getModifiers() == InputEvent.SHIFT_MASK))) {
        int[] selectedRows = profilingPointsTable.getSelectedRows();

        if (selectedRows.length != 0) {
            Rectangle rowBounds = profilingPointsTable.getCellRect(selectedRows[0], 1, true);
            showProfilingPointsPopup(e.getComponent(), rowBounds.x + 20,
                                     rowBounds.y + (profilingPointsTable.getRowHeight() / 2));
        }
    } else if (e.getKeyCode() == KeyEvent.VK_DELETE) {
        deletePPs();
    }
}