Example usage for java.awt.event InputEvent CTRL_DOWN_MASK

List of usage examples for java.awt.event InputEvent CTRL_DOWN_MASK

Introduction

In this page you can find the example usage for java.awt.event InputEvent CTRL_DOWN_MASK.

Prototype

int CTRL_DOWN_MASK

To view the source code for java.awt.event InputEvent CTRL_DOWN_MASK.

Click Source Link

Document

The Control key extended modifier constant.

Usage

From source file:com.evanbelcher.DrillBook.display.DBMenuBar.java

/**
 * Constructs DBMenuBar. Adds the menu and menuitems.
 *
 * @param graphicsRunner the JFrame that created this
 * @param desktop        the DBDesktopPane in the JFrame
 *///from   w w w  . j  a  va  2s . c  om
public DBMenuBar(GraphicsRunner graphicsRunner, DBDesktopPane desktop) {
    super();

    gr = graphicsRunner;
    this.desktop = desktop;

    //Set up the menu
    JMenu menu = new JMenu("File");
    add(menu);

    //Set up the menu items.
    JMenuItem menuItem = new JMenuItem("New");
    menuItem.setMnemonic(KeyEvent.VK_N);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.CTRL_DOWN_MASK));
    menuItem.setActionCommand("new");
    menuItem.addActionListener(this);
    menu.add(menuItem);

    menuItem = new JMenuItem("Open");
    menuItem.setMnemonic(KeyEvent.VK_O);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_DOWN_MASK));
    menuItem.setActionCommand("open");
    menuItem.addActionListener(this);
    menuItem.setLayout(new MigLayout());
    menu.add(menuItem);

    menuItem = new JMenuItem("Save");
    menuItem.setMnemonic(KeyEvent.VK_S);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK));
    menuItem.setActionCommand("save");
    menuItem.addActionListener(this);
    menu.add(menuItem);

    menuItem = new JMenuItem("Save As");
    menuItem.setActionCommand("saveas");
    menuItem.addActionListener(this);
    menu.add(menuItem);

    menuItem = new JMenuItem("Print    Current Page");
    menuItem.setMnemonic(KeyEvent.VK_P);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, InputEvent.CTRL_DOWN_MASK));
    menuItem.setActionCommand("printpage");
    menuItem.addActionListener(this);
    menu.add(menuItem);

    menuItem = new JMenuItem("Print Show");
    menuItem.setActionCommand("printshow");
    menuItem.addActionListener(this);
    menu.add(menuItem);

    menuItem = new JMenuItem("Print Dot Sheets");
    menuItem.setActionCommand("printdotsheets");
    menuItem.addActionListener(this);
    menu.add(menuItem);

    menuItem = new JMenuItem("Quit");
    menuItem.setMnemonic(KeyEvent.VK_Q);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, InputEvent.CTRL_DOWN_MASK));
    menuItem.setActionCommand("quit");
    menuItem.addActionListener(this);
    menu.add(menuItem);

    menu = new JMenu("Edit");
    add(menu);

    menuItem = new JMenuItem("Undo");
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Z, InputEvent.CTRL_DOWN_MASK));
    menuItem.setActionCommand("undo");
    menuItem.addActionListener(this);
    menu.add(menuItem);

    menuItem = new JMenuItem("Redo");
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Y, InputEvent.CTRL_DOWN_MASK));
    menuItem.setActionCommand("redo");
    menuItem.addActionListener(this);
    menu.add(menuItem);

    menu = new JMenu("Settings");
    add(menu);

    menuItem = new JMenuItem("Toggle Gridlines");
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_G, InputEvent.CTRL_DOWN_MASK));
    menuItem.setActionCommand("togglegrid");
    menuItem.addActionListener(this);
    menuItem.setForeground(Main.getState().getSettings().shouldShowGrid() ? Color.BLACK : Color.RED);
    menu.add(menuItem);

    menuItem = new JMenuItem("Toggle Dot Names");
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_D, InputEvent.CTRL_DOWN_MASK));
    menuItem.setActionCommand("togglenames");
    menuItem.addActionListener(this);
    menuItem.setForeground(Main.getState().getSettings().shouldShowNames() ? Color.BLACK : Color.RED);
    menu.add(menuItem);

    menuItem = new JMenuItem("Toggle Text Box");
    menuItem.setActionCommand("toggletext");
    menuItem.addActionListener(this);
    menuItem.setForeground(Main.getState().getSettings().shouldShowText() ? Color.BLACK : Color.RED);
    menu.add(menuItem);

    menuItem = new JMenuItem("Color Code Dots by Instrument");
    menuItem.setActionCommand("colordots");
    menuItem.addActionListener(this);
    menuItem.setForeground(Main.getState().getSettings().shouldColorDots() ? Color.BLACK : Color.RED);
    menu.add(menuItem);

    menuItem = new JMenuItem();
    menuItem.setText(Main.getState().getSettings().useCollegeHashes() ? "Change to High School Hashes"
            : "Change to College Hashes");
    menuItem.setActionCommand("changehash");
    menuItem.addActionListener(this);
    menu.add(menuItem);

    menuItem = new JMenuItem("Change Font Size");
    menuItem.setActionCommand("fontsize");
    menuItem.addActionListener(this);
    menu.add(menuItem);

    //add(Box.createHorizontalStrut(menu.getPreferredSize().width));

    //add these to the menubar itself
    menuItem = new JMenuItem("Play");
    menuItem.setMaximumSize(new Dimension(menuItem.getPreferredSize().width, Integer.MAX_VALUE));
    menuItem.setActionCommand("play");
    menuItem.addActionListener(this);
    add(menuItem);

    add(Box.createHorizontalGlue());

    menu = new JMenu("Help");
    add(menu);

    menuItem = new JMenuItem("Help");
    menuItem.setActionCommand("help");
    menuItem.addActionListener(this);
    menu.add(menuItem);

    menuItem = new JMenuItem("About");
    menuItem.setActionCommand("about");
    menuItem.addActionListener(this);
    menu.add(menuItem);
}

From source file:SWTUtils.java

/**
 * Creates an AWT <code>MouseEvent</code> from a swt event.
 * This method helps passing SWT mouse event to awt components.
 * @param event The swt event./*  ww w  . j a  v  a 2  s.c om*/
 * @return A AWT mouse event based on the given SWT event.
 */
public static MouseEvent toAwtMouseEvent(org.eclipse.swt.events.MouseEvent event) {
    int button = MouseEvent.NOBUTTON;
    switch (event.button) {
    case 1:
        button = MouseEvent.BUTTON1;
        break;
    case 2:
        button = MouseEvent.BUTTON2;
        break;
    case 3:
        button = MouseEvent.BUTTON3;
        break;
    }
    int modifiers = 0;
    if ((event.stateMask & SWT.CTRL) != 0) {
        modifiers |= InputEvent.CTRL_DOWN_MASK;
    }
    if ((event.stateMask & SWT.SHIFT) != 0) {
        modifiers |= InputEvent.SHIFT_DOWN_MASK;
    }
    if ((event.stateMask & SWT.ALT) != 0) {
        modifiers |= InputEvent.ALT_DOWN_MASK;
    }
    MouseEvent awtMouseEvent = new MouseEvent(DUMMY_PANEL, event.hashCode(), event.time, modifiers, event.x,
            event.y, 1, false, button);
    return awtMouseEvent;
}

From source file:com.cburch.draw.tools.LineTool.java

private void updateMouse(Canvas canvas, int mx, int my, int mods) {
    if (active) {
        boolean shift = (mods & MouseEvent.SHIFT_DOWN_MASK) != 0;
        Location newEnd;//from w w w  . j a v a2 s.  c  o  m
        if (shift) {
            newEnd = LineUtil.snapTo8Cardinals(mouseStart, mx, my);
        } else {
            newEnd = Location.create(mx, my);
        }

        if ((mods & InputEvent.CTRL_DOWN_MASK) != 0) {
            int x = newEnd.getX();
            int y = newEnd.getY();
            x = canvas.snapX(x);
            y = canvas.snapY(y);
            newEnd = Location.create(x, y);
        }

        if (!newEnd.equals(mouseEnd)) {
            mouseEnd = newEnd;
            repaintArea(canvas);
        }
    }
    lastMouseX = mx;
    lastMouseY = my;
}

From source file:ee.ioc.cs.vsle.editor.Editor.java

/**
 * Creates Action objects and initializes Input and Action mappings
 *///from  w w  w  . j  a va2 s  .c  o m
private void initActions() {
    JRootPane rp = getRootPane();

    ActionMap am = rp.getActionMap();
    InputMap im = rp.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);

    am.put(DeleteAction.class, deleteAction);
    am.put(CloneAction.class, cloneAction);

    im.put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), DeleteAction.class);
    im.put(KeyStroke.getKeyStroke(KeyEvent.VK_D, InputEvent.CTRL_DOWN_MASK), CloneAction.class);
}

From source file:com.haulmont.cuba.desktop.gui.components.DesktopComponentsHelper.java

/**
 * Convert {@link KeyCombination.Modifier} to {@link InputEvent} modifier constraint.
 *
 * @param modifier modifier to convert/*w  w  w . jav  a  2s  .  c  o m*/
 * @return {@link InputEvent} modifier constraint
 */
public static int convertModifier(KeyCombination.Modifier modifier) {
    switch (modifier) {
    case CTRL:
        return InputEvent.CTRL_DOWN_MASK;
    case ALT:
        return InputEvent.ALT_DOWN_MASK;
    case SHIFT:
        return InputEvent.SHIFT_DOWN_MASK;
    default:
        throw new IllegalArgumentException("Modifier " + modifier.name() + " not recognized");
    }
}

From source file:com.chenjw.imagegrab.ui.MainFrame.java

public MainFrame() {
    {//  w  w w. j ava  2s .  c  o  m
        this.addWindowListener(new WindowAdapter() {

            @Override
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }

        });
    }

    GroupLayout configPanelLayout = new GroupLayout((JComponent) configPanel);
    configPanel.setLayout(configPanelLayout);
    configPanel.setPreferredSize(new java.awt.Dimension(1035, 726));
    {
        downloadButton = new JButton();
        downloadButton.setText("");
        downloadButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                executeService.execute(new Runnable() {
                    @Override
                    public void run() {
                        imagegrabService.grab();
                    }
                });

            }

        });
        downloadButton.registerKeyboardAction(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                executeService.execute(new Runnable() {
                    @Override
                    public void run() {
                        imagegrabService.grab();
                    }
                });
            }
        }, KeyStroke.getKeyStroke(KeyEvent.VK_B, InputEvent.CTRL_DOWN_MASK), JComponent.WHEN_IN_FOCUSED_WINDOW);
    }
    {
        jLabel1 = new JLabel();
        jLabel1.setText("??");
    }
    {
        resultScrollPane = new JScrollPane(resultPane);
        {
            resultPane = new JTextArea();
            resultScrollPane.setViewportView(resultPane);
        }
    }
    {
        sourceComboBox = new JComboBox();
    }
    {

        maxNumComboBox = new HistoryComboBox("maxNum");
    }
    {
        jLabel6 = new JLabel();
        jLabel6.setText("??");
    }
    {
        jLabel3 = new JLabel();
        jLabel3.setText("??");
    }

    {
        searchWordComboBox = new HistoryComboBox("searchWord");
    }
    configPanelLayout.setHorizontalGroup(configPanelLayout.createSequentialGroup().addContainerGap()
            .addGroup(configPanelLayout.createParallelGroup()
                    .addGroup(configPanelLayout.createSequentialGroup()
                            .addComponent(resultScrollPane, GroupLayout.PREFERRED_SIZE, 979,
                                    GroupLayout.PREFERRED_SIZE)
                            .addGap(0, 0, Short.MAX_VALUE))
                    .addGroup(GroupLayout.Alignment.LEADING, configPanelLayout.createSequentialGroup()
                            .addPreferredGap(resultScrollPane, jLabel1, LayoutStyle.ComponentPlacement.INDENT)
                            .addComponent(jLabel1, GroupLayout.PREFERRED_SIZE, 75, GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(searchWordComboBox, 0, 213, Short.MAX_VALUE)
                            .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(jLabel3, GroupLayout.PREFERRED_SIZE, 39, GroupLayout.PREFERRED_SIZE)
                            .addComponent(sourceComboBox, GroupLayout.PREFERRED_SIZE, 112,
                                    GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
                            .addComponent(jLabel6, GroupLayout.PREFERRED_SIZE, 64, GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(maxNumComboBox, GroupLayout.PREFERRED_SIZE, 72,
                                    GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
                            .addComponent(downloadButton, GroupLayout.PREFERRED_SIZE, 162,
                                    GroupLayout.PREFERRED_SIZE)
                            .addGap(0, 164, GroupLayout.PREFERRED_SIZE)))
            .addContainerGap());
    configPanelLayout.setVerticalGroup(configPanelLayout.createSequentialGroup().addContainerGap()
            .addGroup(configPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 27,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 27,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(searchWordComboBox, GroupLayout.Alignment.BASELINE,
                            GroupLayout.PREFERRED_SIZE, 27, GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 27,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(sourceComboBox, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE,
                            27, GroupLayout.PREFERRED_SIZE)
                    .addComponent(downloadButton, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE,
                            27, GroupLayout.PREFERRED_SIZE)
                    .addComponent(maxNumComboBox, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE,
                            27, GroupLayout.PREFERRED_SIZE))
            .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 698, GroupLayout.PREFERRED_SIZE)
            .addComponent(resultScrollPane, GroupLayout.PREFERRED_SIZE, 686, GroupLayout.PREFERRED_SIZE));
    //
    pack();
    this.setSize(1010, 768);
    setVisible(true);
    this.setTitle("?");
    getContentPane().add(configPanel, BorderLayout.CENTER);
    initSpring();
}

From source file:net.erdfelt.android.sdkfido.ui.SdkFidoFrame.java

private void enableExitKey() {
    InputMap rootInput = getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    ActionMap rootAction = getRootPane().getActionMap();

    if (SystemUtils.IS_OS_UNIX || SystemUtils.IS_OS_WINDOWS) {
        rootInput.put(KeyStroke.getKeyStroke(KeyEvent.VK_F4, InputEvent.CTRL_DOWN_MASK), "exit");
        rootInput.put(KeyStroke.getKeyStroke(KeyEvent.VK_Q, InputEvent.CTRL_DOWN_MASK), "exit");
    }//w  w  w.  j  a va2  s  . c o m

    if (SystemUtils.IS_OS_MAC) {
        rootInput.put(KeyStroke.getKeyStroke(KeyEvent.VK_Q, InputEvent.META_DOWN_MASK), "exit");
    }

    rootAction.put("exit", new KeyAction(actionMapper, "exit"));
}

From source file:bio.gcat.gui.BDATool.java

public BDATool() {
    super("BDA Tool - " + AnalysisTool.NAME);
    setIconImage(getImage("bda"));
    setMinimumSize(new Dimension(660, 400));
    setPreferredSize(new Dimension(1020, 400));
    setSize(getPreferredSize());/* w ww  . j av  a 2 s . c o m*/
    setLocationByPlatform(true);
    setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);

    menubar = new JMenuBar();
    menu = new JMenu[4];
    menubar.add(menu[0] = new JMenu("File"));
    menubar.add(menu[1] = new JMenu("Edit"));
    menubar.add(menu[2] = new JMenu("Window"));
    menubar.add(menu[3] = new JMenu("Help"));
    setJMenuBar(menubar);

    menu[0].add(createMenuItem("Open...", "folder-horizontal-open",
            KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_DOWN_MASK), ACTION_OPEN, this));
    menu[0].add(createMenuItem("Save As...", "disk--arrow",
            KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK), ACTION_SAVE_AS, this));
    menu[0].add(createSeparator());
    menu[0].add(createMenuItem("Close Window", "cross", ACTION_CLOSE, this));
    menu[1].add(createMenuText("Binary Dichotomic Algorithm:"));
    menu[1].add(createMenuItem("Add", KeyStroke.getKeyStroke(KeyEvent.VK_A, InputEvent.CTRL_DOWN_MASK),
            ACTION_BDA_ADD, this));
    menu[1].add(createMenuItem("Edit...", KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.CTRL_DOWN_MASK),
            ACTION_BDA_EDIT, this));
    menu[1].add(
            createMenuItem("Remove", KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), ACTION_BDA_REMOVE, this));
    menu[1].add(createMenuItem("Clear", ACTION_BDAS_CLEAR, this));
    menu[1].add(seperateMenuItem(createMenuItem("Move Up",
            KeyStroke.getKeyStroke(KeyEvent.VK_UP, InputEvent.CTRL_DOWN_MASK), ACTION_BDA_MOVE_UP, this)));
    menu[1].add(createMenuItem("Move Down", KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, InputEvent.CTRL_DOWN_MASK),
            ACTION_BDA_MOVE_DOWN, this));
    menu[2].add(createMenuItem("Preferences", ACTION_PREFERENCES, this));
    menu[3].add(createMenuItem("About BDA Tool", "bda", ACTION_ABOUT, this));
    for (String action : new String[] { ACTION_BDA_EDIT, ACTION_BDA_REMOVE, ACTION_BDAS_CLEAR,
            ACTION_BDA_MOVE_UP, ACTION_BDA_MOVE_DOWN })
        getMenuItem(menubar, action).setEnabled(false);
    getMenuItem(menubar, ACTION_PREFERENCES).setEnabled(false);
    registerKeyStroke(getRootPane(), KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "remove",
            new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent event) {
                    if (bdaPanel.table.hasFocus())
                        removeBinaryDichotomicAlgorithm();
                }
            });

    toolbar = new JToolBar[1];
    toolbar[0] = new JToolBar("File");
    toolbar[0].add(createToolbarButton("Open File", "folder-horizontal-open", ACTION_OPEN, this));
    toolbar[0].add(createToolbarButton("Save As File", "disk--arrow", ACTION_SAVE_AS, this));

    toolbars = new JPanel(new FlowLayout(FlowLayout.LEADING));
    for (JToolBar toolbar : toolbar)
        toolbars.add(toolbar);
    add(toolbars, BorderLayout.NORTH);

    add(createSplitPane(JSplitPane.HORIZONTAL_SPLIT, false, true, 360, 0.195,
            new JScrollPane(bdaPanel = new BinaryDichotomicAlgorithmPanel()),
            new JScrollPane(tablePanel = new JPanel(new BorderLayout()))), BorderLayout.CENTER);

    add(bottom = new JPanel(new FlowLayout(FlowLayout.RIGHT)), BorderLayout.SOUTH);

    status = new JLabel();
    status.setBorder(new EmptyBorder(0, 5, 0, 5));
    status.setHorizontalAlignment(JLabel.RIGHT);
    bottom.add(status);

    ((ListTableModel<?>) bdaPanel.table.getModel()).addListDataListener(this);
    bdaPanel.table.getSelectionModel().addListSelectionListener(this);

    revalidateGeneticCodeTable();
}

From source file:DragPictureDemo2.java

public void mouseDragged(MouseEvent e) {
    //Don't bother to drag if the component displays no image.
    if (image == null)
        return;/*from  w  w  w .  j  a v  a  2s . co m*/

    if (firstMouseEvent != null) {
        e.consume();

        //If they are holding down the control key, COPY rather than MOVE
        int ctrlMask = InputEvent.CTRL_DOWN_MASK;
        int action = ((e.getModifiersEx() & ctrlMask) == ctrlMask) ? TransferHandler.COPY
                : TransferHandler.MOVE;

        int dx = Math.abs(e.getX() - firstMouseEvent.getX());
        int dy = Math.abs(e.getY() - firstMouseEvent.getY());
        //Arbitrarily define a 5-pixel shift as the
        //official beginning of a drag.
        if (dx > 5 || dy > 5) {
            //This is a drag, not a click.
            JComponent c = (JComponent) e.getSource();
            TransferHandler handler = c.getTransferHandler();
            //Tell the transfer handler to initiate the drag.
            handler.exportAsDrag(c, firstMouseEvent, action);
            firstMouseEvent = null;
        }
    }
}

From source file:com.varaneckas.hawkscope.cfg.Configuration.java

/**
 * Parses hotkey string and returns int value of modifier.
 * I.e.: InputEvent.CTRL_DOWN_MASK/*from ww  w  .  ja  va 2  s  .  co m*/
 * 
 * @return InputEvent modifier value
 */
public int getHotkeyModifier() {
    final String hotkey = properties.get(HOTKEY_REPR);
    if (hotkey != null && hotkey.contains("+")) {
        //good hotkey
        if (hotkey.startsWith("Shift")) {
            return InputEvent.SHIFT_DOWN_MASK;
        }
        if (hotkey.startsWith("Ctrl")) {
            return InputEvent.CTRL_DOWN_MASK;
        }
        if (hotkey.startsWith("Alt")) {
            return InputEvent.ALT_DOWN_MASK;
        }
        if (hotkey.startsWith("Win") || hotkey.startsWith("Command")) {
            return InputEvent.META_DOWN_MASK;
        }
    }
    //bad hotkey or no hotkey
    return -1;
}