Example usage for java.awt.event InputEvent CTRL_MASK

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

Introduction

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

Prototype

int CTRL_MASK

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

Click Source Link

Document

The Control key modifier constant.

Usage

From source file:com.jcraft.weirdx.DDXWindowImp.java

public void keyPressed(KeyEvent e) {
    if (!window.isMapped())
        return;//from  w  w  w . j a va2s.c o m

    if (e.getKeyCode() == KeyEvent.VK_CAPS_LOCK) {
        if (clck_toggle) {
            clck_toggle = false;
            XWindow.sprite.hot.state &= (~1);
        } else {
            clck_toggle = true;
            XWindow.sprite.hot.state |= 1;
        }
    }

    // Easter Egg...
    if (window == window.screen.root && 0 < px && px < 3 && 0 < py && py < 3) {
        if (((e.getModifiers() & InputEvent.CTRL_MASK) != 0) && e.getKeyCode() == KeyEvent.VK_W) {
            LogoImage.toggle();
        } else if (((e.getModifiers() & InputEvent.CTRL_MASK) != 0) && e.getKeyCode() == KeyEvent.VK_E) {
            XWindow.printWindowTree(window.screen.root);
        }
        //    else if(((e.getModifiers() & InputEvent.CTRL_MASK)!=0) &&
        //         e.getKeyCode()==KeyEvent.VK_I){
        //   if(WeirdX.acontext!=null){
        //     acontext.showDocument(new URL("http://www.weirdx.org/"), "_blank");
        //   }
        //    }
        //    else if(((e.getModifiers() & InputEvent.CTRL_MASK)!=0) &&
        //         e.getKeyCode()==KeyEvent.VK_R){
        //   }
        //    }
        //    else if(((e.getModifiers() & InputEvent.CTRL_MASK)!=0) &&
        //         e.getKeyCode()==KeyEvent.VK_D){
        //   }
        //    }
        //    else if(((e.getModifiers() & InputEvent.CTRL_MASK)!=0) &&
        //         e.getKeyCode()==KeyEvent.VK_X){
        //   }
        //    }
    }

    XWindow dest = XWindow.sprite.win;
    if (XWindow.focus.window != null)
        dest = XWindow.focus.window;

    if (window.screen.windowmode != 0 && dest == window.screen.root) {
        if (XWindow.focus.window != null)
            dest = XWindow.sprite.win;
        else
            dest = window;
    }

    if (dest.client == null)
        return;

    int kcode = Keymap.km.getCode(e);
    event.mkKeyPress(kcode, window.screen.rootId, dest.id, 0, XWindow.sprite.hot.x, XWindow.sprite.hot.y,
            XWindow.sprite.hot.x - window.x, XWindow.sprite.hot.y - window.y, XWindow.sprite.hot.state, 1);

    try {
        if (XWindow.grab != null)
            XWindow.sendGrabbedEvent(event, false, 1);
        else
            XWindow.sendDeviceEvent(dest, event, XWindow.grab, null, 1);
    } catch (Exception ee) {
    }

    kcode = e.getKeyCode();
    int state = XWindow.sprite.hot.state;
    if (kcode == KeyEvent.VK_CONTROL) {
        if ((state & 4) == 0)
            state |= 4;
    } else if (kcode == KeyEvent.VK_SHIFT) {
        if ((state & 1) == 0)
            state |= 1;
    } else if (kcode == KeyEvent.VK_ALT) {
        if ((state & 8) == 0)
            state |= 8;
    } else if (kcode == VK_ALT_GRAPH) {
        if ((state & ALT_GR_MASK) == 0)
            state |= ALT_GR_MASK;
    }
    // check for windoze ALT_GR (is equal to ALT+CONTROL)
    if ((state & 12) == 12) {
        state -= 12;
        state |= ALT_GR_MASK;
    }
    XWindow.sprite.hot.state = state;
}

From source file:com.isencia.passerelle.hmi.generic.GenericHMI.java

public void addPrefsMenu(final JMenuBar menuBar) {
    final JMenu prefsMenu = new JMenu(HMIMessages.getString(HMIMessages.MENU_PREFS));
    prefsMenu.setMnemonic(HMIMessages.getString(HMIMessages.MENU_PREFS + HMIMessages.KEY).charAt(0));
    final JMenuItem layoutMenuItem = new JMenuItem(HMIMessages.getString(HMIMessages.MENU_LAYOUT),
            HMIMessages.getString(HMIMessages.MENU_LAYOUT + HMIMessages.KEY).charAt(0));
    layoutMenuItem.addActionListener(new ColumnCountDialogOpener());
    prefsMenu.add(layoutMenuItem);//from   w w  w. java2 s. c o m
    final JMenuItem actorOrderMenuItem = new JMenuItem(HMIMessages.getString(HMIMessages.MENU_ACTOR_ORDER),
            HMIMessages.getString(HMIMessages.MENU_ACTOR_ORDER + HMIMessages.KEY).charAt(0));
    actorOrderMenuItem.addActionListener(new ActorOrderOpener());
    prefsMenu.add(actorOrderMenuItem);
    final JMenuItem paramFilterMenuItem = new JMenuItem(
            HMIMessages.getString(HMIMessages.MENU_PARAM_VISIBILITY),
            HMIMessages.getString(HMIMessages.MENU_PARAM_VISIBILITY + HMIMessages.KEY).charAt(0));
    paramFilterMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, InputEvent.CTRL_MASK));
    paramFilterMenuItem.addActionListener(new ParameterFilterOpener());
    prefsMenu.add(paramFilterMenuItem);
    menuBar.add(prefsMenu);

    StateMachine.getInstance().registerActionForState(StateMachine.MODEL_OPEN, HMIMessages.MENU_PREFS,
            prefsMenu);
}

From source file:edu.harvard.i2b2.query.QueryConceptTreePanel.java

private void createPopupMenu() {
    JMenuItem menuItem;//from  www. j  av  a2s  . c  o  m

    //Create the popup menu.
    JPopupMenu popup = new JPopupMenu();
    /*menuItem = new JMenuItem("Constrain Item ...");
    menuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C, 
      java.awt.event.InputEvent.CTRL_MASK));
    menuItem.addActionListener(this);
    popup.add(menuItem);*/

    menuItem = new JMenuItem("Delete Item");
    menuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_X,
            java.awt.event.InputEvent.CTRL_MASK));
    menuItem.addActionListener(this);
    popup.add(menuItem);

    /*popup.add(new javax.swing.JSeparator());
            
    menuItem = new JMenuItem("Exclude All Items");
    menuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_A, 
      java.awt.event.InputEvent.CTRL_MASK));
    menuItem.addActionListener(this);
    popup.add(menuItem);*/

    //Add listener to the tree
    MouseListener popupListener = new ConceptTreePopupListener(popup);
    jTree1.addMouseListener(popupListener);
}

From source file:de.dmarcini.submatix.pclogger.gui.MainCommGUI.java

/**
 * Initialize the contents of the frame.
 * /*  w w w  .j a v  a  2s. co  m*/
 * @throws ClassNotFoundException
 * @throws SQLException
 */
private void initializeGUI() throws SQLException, ClassNotFoundException {
    frmMainWindow = new JFrame();
    frmMainWindow.setFont(new Font("Arial", Font.PLAIN, 12));
    frmMainWindow.setSize(new Dimension(810, 600));
    frmMainWindow.setResizable(false);
    frmMainWindow.setIconImage(Toolkit.getDefaultToolkit()
            .getImage(MainCommGUI.class.getResource("/de/dmarcini/submatix/pclogger/res/112.png")));
    frmMainWindow.setTitle(LangStrings.getString("MainCommGUI.frmMainWindow.title")); //$NON-NLS-1$
    frmMainWindow.setBounds(100, 100, 800, 600);
    frmMainWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frmMainWindow.getContentPane().setLayout(new BorderLayout(0, 0));
    frmMainWindow.addWindowListener(new MainWindowListener());
    statusTextField = new JTextField();
    statusTextField.setEditable(false);
    statusTextField.setText("-");
    frmMainWindow.getContentPane().add(statusTextField, BorderLayout.SOUTH);
    statusTextField.setColumns(10);
    tabbedPane = new JTabbedPane(JTabbedPane.TOP);
    frmMainWindow.getContentPane().add(tabbedPane, BorderLayout.CENTER);
    tabbedPane.addMouseMotionListener(this);
    // Connection Panel
    connectionPanel = new spx42ConnectPanel(databaseUtil);
    tabbedPane.addTab("CONNECTION", null, connectionPanel, null);
    tabbedPane.setEnabledAt(programTabs.TAB_CONNECT.ordinal(), true);
    // config Panel
    configPanel = new spx42ConfigPanel();
    tabbedPane.addTab("CONFIG", null, configPanel, null);
    tabbedPane.setEnabledAt(programTabs.TAB_CONFIG.ordinal(), true);
    // GASPANEL
    gasConfigPanel = new spx42GaslistEditPanel(databaseUtil);
    tabbedPane.addTab("GAS", null, gasConfigPanel, null);
    tabbedPane.setEnabledAt(programTabs.TAB_GASLIST.ordinal(), true);
    // Loglisten Panel
    logListPanel = new spx42LoglistPanel(this, databaseUtil);
    tabbedPane.addTab("LOG", null, logListPanel, null);
    tabbedPane.setEnabledAt(programTabs.TAB_LOGREAD.ordinal(), true);
    // Grafik Panel
    logGraphPanel = new spx42LogGraphPanel(databaseUtil);
    tabbedPane.addTab("GRAPH", null, logGraphPanel, null);
    tabbedPane.setEnabledAt(programTabs.TAB_LOGGRAPH.ordinal(), true);
    // import/export Panel
    fileManagerPanel = new spx42FileManagerPanel(this, databaseUtil);
    tabbedPane.addTab("EXPORT", null, fileManagerPanel, null);
    tabbedPane.setEnabledAt(programTabs.TAB_FILEMANAGER.ordinal(), true);
    // MEN
    JMenuBar menuBar = new JMenuBar();
    frmMainWindow.setJMenuBar(menuBar);
    mnFile = new JMenu(LangStrings.getString("MainCommGUI.mnFile.text")); //$NON-NLS-1$
    menuBar.add(mnFile);
    mntmExit = new JMenuItem(LangStrings.getString("MainCommGUI.mntmExit.text")); //$NON-NLS-1$
    mntmExit.setIcon(
            new ImageIcon(MainCommGUI.class.getResource("/de/dmarcini/submatix/pclogger/res/176.png")));
    mntmExit.setActionCommand("exit");
    mntmExit.addActionListener(this);
    mntmExit.addMouseMotionListener(this);
    mntmExit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.CTRL_MASK));
    mnFile.add(mntmExit);
    mnLanguages = new JMenu(LangStrings.getString("MainCommGUI.mnLanguages.text")); //$NON-NLS-1$
    mnLanguages.addMouseMotionListener(this);
    menuBar.add(mnLanguages);
    mnOptions = new JMenu(LangStrings.getString("MainCommGUI.mnOptions.text")); //$NON-NLS-1$
    mnOptions.addMouseMotionListener(this);
    menuBar.add(mnOptions);
    mntmOptions = new JMenuItem(LangStrings.getString("MainCommGUI.mntmOptions.text")); //$NON-NLS-1$
    mntmOptions.addMouseMotionListener(this);
    mntmOptions.addActionListener(this);
    mntmOptions.setActionCommand("set_propertys");
    mnOptions.add(mntmOptions);
    mnHelp = new JMenu(LangStrings.getString("MainCommGUI.mnHelp.text")); //$NON-NLS-1$
    mnHelp.addMouseMotionListener(this);
    menuBar.add(mnHelp);
    mntmHelp = new JMenuItem(LangStrings.getString("MainCommGUI.mntmHelp.text")); //$NON-NLS-1$
    mntmHelp.addActionListener(this);
    mntmHelp.setActionCommand("help");
    mntmHelp.addMouseMotionListener(this);
    mnHelp.add(mntmHelp);
    mntmInfo = new JMenuItem(LangStrings.getString("MainCommGUI.mntmInfo.text")); //$NON-NLS-1$
    mntmInfo.addActionListener(this);
    mntmInfo.setActionCommand("info");
    mntmInfo.addMouseMotionListener(this);
    mntmInfo.setIcon(
            new ImageIcon(MainCommGUI.class.getResource("/javax/swing/plaf/metal/icons/ocean/expanded.gif")));
    mntmInfo.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_I, InputEvent.CTRL_MASK));
    mnHelp.add(mntmInfo);
}

From source file:edu.harvard.i2b2.query.ui.QueryConceptTreePanel.java

private void createPopupMenu() {
    JMenuItem menuItem;/*from  w w  w .java2s  .c om*/

    //Create the popup menu.
    JPopupMenu popup = new JPopupMenu();
    /*menuItem = new JMenuItem("Constrain Item ...");
      menuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C, 
      java.awt.event.InputEvent.CTRL_MASK));
      menuItem.addActionListener(this);
      popup.add(menuItem);*/

    menuItem = new JMenuItem("Delete Item");
    menuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_X,
            java.awt.event.InputEvent.CTRL_MASK));
    menuItem.addActionListener(this);
    popup.add(menuItem);

    /*popup.add(new javax.swing.JSeparator());
            
      menuItem = new JMenuItem("Exclude All Items");
      menuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_A, 
      java.awt.event.InputEvent.CTRL_MASK));
      menuItem.addActionListener(this);
      popup.add(menuItem);*/

    popup.add(new javax.swing.JSeparator());

    menuItem = new JMenuItem("Set Value ...");
    menuItem.setEnabled(false);
    menuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S,
            java.awt.event.InputEvent.CTRL_MASK));
    menuItem.addActionListener(this);
    popup.add(menuItem);

    //Add listener to the tree
    MouseListener popupListener = new ConceptTreePopupListener(popup);
    jTree1.addMouseListener(popupListener);
}

From source file:ExText.java

/**
 * Process a new wakeup. Interpret mouse button presses, releases, and mouse
 * drags./* ww  w.  j a va 2s. c o  m*/
 * 
 * @param criteria
 *            The wakeup criteria causing the behavior wakeup.
 */
public void processStimulus(Enumeration criteria) {
    WakeupCriterion wakeup = null;
    AWTEvent[] event = null;
    int whichButton = BUTTONNONE;

    // Process all pending wakeups
    while (criteria.hasMoreElements()) {
        wakeup = (WakeupCriterion) criteria.nextElement();
        if (wakeup instanceof WakeupOnAWTEvent) {
            event = ((WakeupOnAWTEvent) wakeup).getAWTEvent();

            // Process all pending events
            for (int i = 0; i < event.length; i++) {
                if (event[i].getID() != MouseEvent.MOUSE_PRESSED
                        && event[i].getID() != MouseEvent.MOUSE_RELEASED
                        && event[i].getID() != MouseEvent.MOUSE_DRAGGED)
                    // Ignore uninteresting mouse events
                    continue;

                //
                // Regretably, Java event handling (or perhaps
                // underlying OS event handling) doesn't always
                // catch button bounces (redundant presses and
                // releases), or order events so that the last
                // drag event is delivered before a release.
                // This means we can get stray events that we
                // filter out here.
                //
                if (event[i].getID() == MouseEvent.MOUSE_PRESSED && buttonPressed != BUTTONNONE)
                    // Ignore additional button presses until a release
                    continue;

                if (event[i].getID() == MouseEvent.MOUSE_RELEASED && buttonPressed == BUTTONNONE)
                    // Ignore additional button releases until a press
                    continue;

                if (event[i].getID() == MouseEvent.MOUSE_DRAGGED && buttonPressed == BUTTONNONE)
                    // Ignore drags until a press
                    continue;

                MouseEvent mev = (MouseEvent) event[i];
                int modifiers = mev.getModifiers();

                //
                // Unfortunately, the underlying event handling
                // doesn't do a "grab" operation when a mouse button
                // is pressed. This means that once a button is
                // pressed, if another mouse button or a keyboard
                // modifier key is pressed, the delivered mouse event
                // will show that a different button is being held
                // down. For instance:
                //
                // Action Event
                //  Button 1 press Button 1 press
                //  Drag with button 1 down Button 1 drag
                //  ALT press -
                //  Drag with ALT & button 1 down Button 2 drag
                //  Button 1 release Button 2 release
                //
                // The upshot is that we can get a button press
                // without a matching release, and the button
                // associated with a drag can change mid-drag.
                //
                // To fix this, we watch for an initial button
                // press, and thenceforth consider that button
                // to be the one held down, even if additional
                // buttons get pressed, and despite what is
                // reported in the event. Only when a button is
                // released, do we end such a grab.
                //

                if (buttonPressed == BUTTONNONE) {
                    // No button is pressed yet, figure out which
                    // button is down now and how to direct events
                    if (((modifiers & InputEvent.BUTTON3_MASK) != 0)
                            || (((modifiers & InputEvent.BUTTON1_MASK) != 0)
                                    && ((modifiers & InputEvent.CTRL_MASK) == InputEvent.CTRL_MASK))) {
                        // Button 3 activity (META or CTRL down)
                        whichButton = BUTTON3;
                    } else if ((modifiers & InputEvent.BUTTON2_MASK) != 0) {
                        // Button 2 activity (ALT down)
                        whichButton = BUTTON2;
                    } else {
                        // Button 1 activity (no modifiers down)
                        whichButton = BUTTON1;
                    }

                    // If the event is to press a button, then
                    // record that that button is now down
                    if (event[i].getID() == MouseEvent.MOUSE_PRESSED)
                        buttonPressed = whichButton;
                } else {
                    // Otherwise a button was pressed earlier and
                    // hasn't been released yet. Assign all further
                    // events to it, even if ALT, META, CTRL, or
                    // another button has been pressed as well.
                    whichButton = buttonPressed;
                }

                // Distribute the event
                switch (whichButton) {
                case BUTTON1:
                    onButton1(mev);
                    break;
                case BUTTON2:
                    onButton2(mev);
                    break;
                case BUTTON3:
                    onButton3(mev);
                    break;
                default:
                    break;
                }

                // If the event is to release a button, then
                // record that that button is now up
                if (event[i].getID() == MouseEvent.MOUSE_RELEASED)
                    buttonPressed = BUTTONNONE;
            }
            continue;
        }

        if (wakeup instanceof WakeupOnElapsedFrames) {
            onElapsedFrames((WakeupOnElapsedFrames) wakeup);
            continue;
        }
    }

    // Reschedule us for another wakeup
    wakeupOn(mouseCriterion);
}

From source file:org.forester.archaeopteryx.TreePanel.java

final void mouseClicked(final MouseEvent e) {
    if (getOptions().isShowOverview() && isOvOn() && isInOv()) {
        final double w_ratio = getVisibleRect().width / getOvRectangle().getWidth();
        final double h_ratio = getVisibleRect().height / getOvRectangle().getHeight();
        double x = (e.getX() - getVisibleRect().x - getOvXPosition() - getOvRectangle().getWidth() / 2.0)
                * w_ratio;/*from ww w  .j  a  va 2s .c om*/
        double y = (e.getY() - getVisibleRect().y - getOvYPosition() - getOvRectangle().getHeight() / 2.0)
                * h_ratio;
        if (x < 0) {
            x = 0;
        }
        if (y < 0) {
            y = 0;
        }
        final double max_x = getWidth() - getVisibleRect().width;
        final double max_y = getHeight() - getVisibleRect().height;
        if (x > max_x) {
            x = max_x;
        }
        if (y > max_y) {
            y = max_y;
        }
        getMainPanel().getCurrentScrollPane().getViewport()
                .setViewPosition(new Point(ForesterUtil.roundToInt(x), ForesterUtil.roundToInt(y)));
        setInOvRect(true);
        repaint();
    } else if (findNode(e.getX(), e.getY()) != null) {

        if ((_control_panel.getActionWhenNodeClicked() == NodeClickAction.SHOW_BRANCH_DATA)
                || (_control_panel.getActionWhenNodeClicked() == NodeClickAction.SHOW_DATA)) {
            _control_panel.setActionWhenNodeClicked(NodeClickAction.SHOW_DATA);
        }
        //System.out.println(_control_panel.getActionWhenNodeClicked());
        final PhylogenyNode node = findNode(e.getX(), e.getY());
        if (node != null) {
            if (!node.isRoot() && node.getParent().isCollapse()) {
                return;
            }
            _highlight_node = node;
            // Check if shift key is down
            if ((e.getModifiers() & InputEvent.SHIFT_MASK) != 0) {
                // Yes, so add to _found_nodes
                if (getFoundNodes() == null) {
                    setFoundNodes(new HashSet<PhylogenyNode>());
                }
                getFoundNodes().add(node);
                // Check if control key is down
            } else if ((e.getModifiers() & InputEvent.CTRL_MASK) != 0) {
                // Yes, so pop-up menu
                displayNodePopupMenu(node, e.getX(), e.getY());
                // Handle unadorned click
            } else {
                // Check for right mouse button
                if (e.getModifiers() == 4) {
                    displayNodePopupMenu(node, e.getX(), e.getY());
                } else {
                    // if not in _found_nodes, clear _found_nodes

                    if (_control_panel.getActionWhenNodeClicked().equals(NodeClickAction.REROOT)) {
                        // no rerooting for nodes anymore
                    } else {
                        handleClickToAction(_control_panel.getActionWhenNodeClicked(), node);
                    }

                }
            }
        }
    }

    else if (findBranch(e.getX(), e.getY()) != null) {
        final PhylogenyNode node = findBranch(e.getX(), e.getY());
        // Check for right mouse button
        if (e.getModifiers() == 4) {
            displayBranchPopupMenu(node, e.getX(), e.getY());
        } else {
            if ((_control_panel.getActionWhenNodeClicked() == NodeClickAction.SHOW_BRANCH_DATA)
                    || (_control_panel.getActionWhenNodeClicked() == NodeClickAction.SHOW_DATA)) {
                _control_panel.setActionWhenNodeClicked(NodeClickAction.SHOW_BRANCH_DATA);
            }
            handleClickToAction(_control_panel.getActionWhenNodeClicked(), node);
        }
    }

    else {

        // no node was clicked
        _highlight_node = null;

    }
    repaint();
}

From source file:com.mirth.connect.client.ui.Frame.java

public synchronized void updateAcceleratorKeyPressed(InputEvent e) {
    this.acceleratorKeyPressed = (((e.getModifiers()
            & Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()) > 0)
            || ((e.getModifiers() & InputEvent.CTRL_MASK) > 0)
            || ((e.getModifiers() & InputEvent.ALT_MASK) > 0));
}

From source file:op.FrmMain.java

private CollapsiblePane addNursingRecords(final Station station) {
    //        bwButtonMap = new HashMap<Resident, JideButton>();

    EntityManager em = OPDE.createEM();/* w ww .ja  va  2  s.co m*/
    Query query;
    if (station == null) {
        query = em.createQuery("SELECT b FROM Resident b WHERE b.station IS NULL ORDER BY b.name, b.firstname");
    } else {
        query = em.createQuery(
                "SELECT b FROM Resident b WHERE b.station = :station ORDER BY b.name, b.firstname");
        query.setParameter("station", station);
    }
    ArrayList<Resident> residentList = new ArrayList<Resident>(query.getResultList());
    em.close();

    CollapsiblePane mypane = new CollapsiblePane(
            station == null ? SYSTools.xx("misc.msg.Archive") : station.getName());
    mypane.setFont(SYSConst.ARIAL14);
    mypane.setEmphasized(station != null && station.equals(StationTools.getStationForThisHost()));
    mypane.setStyle(CollapsiblePane.PLAIN_STYLE);

    JPanel labelPanel = new JPanel();
    labelPanel.setLayout(new VerticalLayout());
    labelPanel.setBackground(Color.WHITE);

    try {
        mypane.setCollapsed(!mypane.isEmphasized());
    } catch (PropertyVetoException e) {
        e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
    }

    if (!residentList.isEmpty() && station != null) {
        JideButton button = GUITools.createHyperlinkButton("opde.mainframe.printdailyplan",
                SYSConst.icon22print2, new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        if ((e.getModifiers() & InputEvent.CTRL_MASK) != 0) {
                            PrescriptionTools.printDailyPlan(station, "html");
                        } else {
                            PrescriptionTools.printDailyPlan(station, "pdf");
                        }
                    }
                });
        button.setBackground(Color.WHITE);
        labelPanel.add(button);
    }

    for (final Resident resident : residentList) {
        ActionListener actionListener = new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent actionEvent) {
                if (currentResident != resident) {

                    if (previousProgButton != null) {
                        previousProgButton.setBackground(Color.WHITE);
                        previousProgButton.setOpaque(false);
                    }

                    previousProgButton = (JideButton) actionEvent.getSource();
                    previousProgButton.setBackground(Color.YELLOW);
                    previousProgButton.setOpaque(true);

                    currentResident = resident;

                    if (currentVisiblePanel instanceof PnlCare) {
                        ((NursingRecordsPanel) currentVisiblePanel).switchResident(resident);
                    } else {
                        setPanelTo(new PnlCare(resident, jspSearch));
                    }

                }
            }
        };

        JPanel singleButtonPanel = new JPanel();
        singleButtonPanel.setLayout(new BoxLayout(singleButtonPanel, BoxLayout.X_AXIS));
        singleButtonPanel.setBorder(null);

        singleButtonPanel.setOpaque(false);

        String titel = resident.getName() + ", " + resident.getFirstname() + " [" + resident.getRIDAnonymous()
                + "]";
        JideButton button = GUITools.createHyperlinkButton(titel, null, actionListener);
        button.setForegroundOfState(ThemePainter.STATE_DEFAULT,
                resident.getGender() == ResidentTools.FEMALE ? Color.red : Color.blue);
        button.setBackground(Color.WHITE);

        singleButtonPanel.add(button);

        OPDE.getDisplayManager().clearSubMessages();

        if (station != null) { // not for the archive
            JPanel pnl = new JPanel();
            pnl.setLayout(new BoxLayout(pnl, BoxLayout.X_AXIS));
            pnl.setOpaque(false);
            pnl.setBorder(null);

            setIconPanel(pnl, resident);

            synchronized (iconPanels) {
                iconPanels.put(resident, pnl);
            }

            singleButtonPanel.add(pnl);
        }

        labelPanel.add(singleButtonPanel);
    }

    mypane.setContentPane(labelPanel);
    listOfNursingrecords.add(mypane);
    return mypane;
}

From source file:org.eclipse.jubula.rc.common.driver.KeyTyper.java

/**
 * @param keyStroke KeyStroke whose modifiers are requested
 * @return a List of KeyCodes (hopefully) realising the ModifierMask contained in the KeyStroke
 *///from ww w  .j av  a2s .  c o  m
private List modifierKeyCodes(KeyStroke keyStroke) {
    List l = new LinkedList();
    int modifiers = keyStroke.getModifiers();
    // this is jdk 1.3 - code.
    // use ALT_DOWN_MASK instead etc. with jdk 1.4 !
    if ((modifiers & InputEvent.ALT_MASK) != 0) {
        l.add(new Integer(KeyEvent.VK_ALT));
    }
    if ((modifiers & InputEvent.ALT_GRAPH_MASK) != 0) {
        l.add(new Integer(KeyEvent.VK_ALT_GRAPH));
    }
    if ((modifiers & InputEvent.CTRL_MASK) != 0) {
        l.add(new Integer(KeyEvent.VK_CONTROL));
    }
    if ((modifiers & InputEvent.SHIFT_MASK) != 0) {
        l.add(new Integer(KeyEvent.VK_SHIFT));
    }
    if ((modifiers & InputEvent.META_MASK) != 0) {
        l.add(new Integer(KeyEvent.VK_META));
    }
    return l;
}