Example usage for java.awt AWTEvent MOUSE_EVENT_MASK

List of usage examples for java.awt AWTEvent MOUSE_EVENT_MASK

Introduction

In this page you can find the example usage for java.awt AWTEvent MOUSE_EVENT_MASK.

Prototype

long MOUSE_EVENT_MASK

To view the source code for java.awt AWTEvent MOUSE_EVENT_MASK.

Click Source Link

Document

The event mask for selecting mouse events.

Usage

From source file:org.eclipse.jubula.rc.swing.driver.RobotAwtImpl.java

/**
 * Clicks at the current mouse position.
 * //w  w  w.  j  a v  a 2s  .c o  m
 * @param graphicsComponent The component used for confirming the click.
 * @param clickOptions Configuration for the click.
 */
private void clickImpl(Object graphicsComponent, ClickOptions clickOptions) {

    int buttonMask = getButtonMask(clickOptions.getMouseButton());
    int clickCount = clickOptions.getClickCount();
    int[] modifierMask = getModifierMask(clickOptions.getClickModifier());
    if (clickCount > 0) {
        IRobotEventConfirmer confirmer = null;
        if (clickOptions.isConfirmClick()) {
            InterceptorOptions options = new InterceptorOptions(new long[] { AWTEvent.MOUSE_EVENT_MASK });
            confirmer = m_interceptor.intercept(options);
        }
        try {
            pressModifier(modifierMask);
            RobotTiming.sleepPreClickDelay();

            for (int i = 0; i < clickCount; i++) {
                m_robot.mousePress(buttonMask);
                RobotTiming.sleepPostMouseDownDelay();
                m_eventFlusher.flush();

                m_robot.mouseRelease(buttonMask);
                RobotTiming.sleepPostMouseUpDelay();
                m_eventFlusher.flush();
            }
            if (confirmer != null) {
                confirmer.waitToConfirm(graphicsComponent, new ClickAwtEventMatcher(clickOptions));
            }
        } finally {
            releaseModifier(modifierMask);
        }
    }
}

From source file:org.tinymediamanager.ui.MainWindow.java

/**
 * Initialize the contents of the frame.
 *//*from   w ww  . j av a 2s.c om*/
private void initialize() {
    // set the logo
    setIconImages(LOGOS);
    setBounds(5, 5, 1100, 727);
    // do nothing, we have our own windowClosing() listener
    // setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    getContentPane().setLayout(new BorderLayout(0, 0));

    JLayeredPane content = new JLayeredPane();
    content.setLayout(new FormLayout(
            new ColumnSpec[] { ColumnSpec.decode("default:grow"), FormFactory.RELATED_GAP_COLSPEC,
                    ColumnSpec.decode("right:270px"), },
            new RowSpec[] { RowSpec.decode("fill:max(500px;default):grow"), }));
    getContentPane().add(content, BorderLayout.CENTER);

    JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new FormLayout(new ColumnSpec[] { ColumnSpec.decode("default:grow") },
            new RowSpec[] { RowSpec.decode("fill:max(500px;default):grow") }));
    content.add(mainPanel, "1, 1, 3, 1, fill, fill");
    content.setLayer(mainPanel, 1);

    JTabbedPane tabbedPane = VerticalTextIcon.createTabbedPane(JTabbedPane.LEFT);
    tabbedPane.setTabPlacement(JTabbedPane.LEFT);
    mainPanel.add(tabbedPane, "1, 1, fill, fill");
    // getContentPane().add(tabbedPane, "1, 2, fill, fill");

    panelStatusBar = new StatusBar();
    getContentPane().add(panelStatusBar, BorderLayout.SOUTH);

    panelMovies = new MoviePanel();
    VerticalTextIcon.addTab(tabbedPane, BUNDLE.getString("tmm.movies"), panelMovies); //$NON-NLS-1$

    panelMovieSets = new MovieSetPanel();
    VerticalTextIcon.addTab(tabbedPane, BUNDLE.getString("tmm.moviesets"), panelMovieSets); //$NON-NLS-1$

    panelTvShows = new TvShowPanel();
    VerticalTextIcon.addTab(tabbedPane, BUNDLE.getString("tmm.tvshows"), panelTvShows); //$NON-NLS-1$

    // shutdown listener - to clean database connections safely
    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            closeTmm();
        }
    });

    MessageManager.instance.addListener(TmmUIMessageCollector.instance);

    // mouse event listener for context menu
    Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
        @Override
        public void eventDispatched(AWTEvent arg0) {
            if (arg0 instanceof MouseEvent && MouseEvent.MOUSE_RELEASED == arg0.getID()
                    && arg0.getSource() instanceof JTextComponent) {
                MouseEvent me = (MouseEvent) arg0;
                JTextComponent tc = (JTextComponent) arg0.getSource();
                if (me.isPopupTrigger() && tc.getComponentPopupMenu() == null) {
                    TextFieldPopupMenu.buildCutCopyPaste().show(tc, me.getX(), me.getY());
                }
            }
        }
    }, AWTEvent.MOUSE_EVENT_MASK);

    // temp info for users using Java 6
    if (SystemUtils.IS_JAVA_1_6) {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                JOptionPane.showMessageDialog(MainWindow.this, BUNDLE.getString("tmm.java6")); //$NON-NLS-1$
            }
        });
    }

    // inform user is MI could not be loaded
    if (Platform.isLinux() && StringUtils.isBlank(MediaInfo.version())) {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                JOptionPane.showMessageDialog(MainWindow.this, BUNDLE.getString("mediainfo.failed.linux")); //$NON-NLS-1$
            }
        });
    }
}