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:MainClass.java

public void init() {
    i = getImage(getDocumentBase(), "ora-icon.gif");
    pg = new PixelGrabber(i, 0, 0, -1, -1, false);
    pg.startGrabbing();//from  ww  w  .  j  av  a  2s. co m
    enableEvents(AWTEvent.MOUSE_EVENT_MASK);
}

From source file:ItemEventComponent.java

ItemEventComponent() {
    enableEvents(AWTEvent.MOUSE_EVENT_MASK);
}

From source file:Main.java

/** The constructor: register the event types we are interested in */
public Main() {/* w ww .j  a  v  a  2  s  . co  m*/
    // We're interested in all types of events
    this.enableEvents(AWTEvent.MOUSE_EVENT_MASK | AWTEvent.MOUSE_MOTION_EVENT_MASK | AWTEvent.KEY_EVENT_MASK
            | AWTEvent.FOCUS_EVENT_MASK | AWTEvent.COMPONENT_EVENT_MASK | AWTEvent.WINDOW_EVENT_MASK);
    this.setPreferredSize(new Dimension(500, 400));
}

From source file:EventTestPane.java

/** The constructor: register the event types we are interested in */
public EventTestPane() {
    // We're interested in all types of events
    this.enableEvents(AWTEvent.MOUSE_EVENT_MASK | AWTEvent.MOUSE_MOTION_EVENT_MASK | AWTEvent.KEY_EVENT_MASK
            | AWTEvent.FOCUS_EVENT_MASK | AWTEvent.COMPONENT_EVENT_MASK | AWTEvent.WINDOW_EVENT_MASK);
    this.setPreferredSize(new Dimension(500, 400));
}

From source file:Main.java

public Main() {
    label = new JLabel("Waiting...");
    frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(label);/*from w w w  . j ava 2  s . c o m*/
    frame.setSize(200, 200);
    frame.setVisible(true);

    Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
        int count;

        @Override
        public void eventDispatched(AWTEvent event) {
            Object source = event.getSource();
            if (source instanceof Component) {
                Component comp = (Component) source;
                Window win = null;
                if (comp instanceof Window) {
                    win = (Window) comp;
                } else {
                    win = SwingUtilities.windowForComponent(comp);
                }
                if (win == frame) {
                    timer.restart();
                    label.setText("Interrupted..." + (++count));
                }
            }
        }
    }, AWTEvent.KEY_EVENT_MASK | AWTEvent.MOUSE_EVENT_MASK | AWTEvent.MOUSE_MOTION_EVENT_MASK
            | AWTEvent.MOUSE_WHEEL_EVENT_MASK);

    timer = new Timer(5000, new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            frame.dispose();
        }
    });
    timer.start();
}

From source file:Main.java

@Override
public void installUI(JComponent c) {
    super.installUI(c);
    ((JLayer) c).setLayerEventMask(AWTEvent.MOUSE_EVENT_MASK | AWTEvent.MOUSE_MOTION_EVENT_MASK);
}

From source file:Diva.java

@Override
public void installUI(JComponent c) {
    super.installUI(c);
    JLayer jlayer = (JLayer) c;
    jlayer.setLayerEventMask(AWTEvent.MOUSE_EVENT_MASK | AWTEvent.MOUSE_MOTION_EVENT_MASK);
}

From source file:AppletMenuBarDemo.java

/**
 * Create a new component that simulates a menubar by displaying the
 * specified labels. Whenever the user clicks the specified label, popup up
 * the PopupMenu specified in the menus array. Elements of the menus arra
 * may be a static PopupMenu object, or a PopupMenuFactory object for
 * dynamically creating menus. Perhaps we'll also provide some other kind of
 * constructor or factory method that reads popup menus out of a config
 * file./*from   w ww  .j ava2 s. c  o m*/
 */
public AppletMenuBar() {
    // We'd like these kinds of events to be delivered
    enableEvents(AWTEvent.MOUSE_EVENT_MASK | AWTEvent.MOUSE_MOTION_EVENT_MASK);
}

From source file:com.haulmont.cuba.desktop.sys.DesktopToolTipManager.java

protected DesktopToolTipManager() {
    closeTimer = new Timer(CLOSE_TIME, null);
    closeTimer.setRepeats(false);/*from  w  ww  . j ava2  s  .  com*/
    closeTimer.addActionListener(e -> {
        if (window != null) {
            window.hide();
            window = null;
            tooltipShowing = false;
            toolTipWindow.removeMouseListener(DesktopToolTipManager.this);
            component.removeMouseListener(DesktopToolTipManager.this);
        }
    });

    Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
        protected MouseEvent event;

        @Override
        public void eventDispatched(AWTEvent e) {
            if (!tooltipShowing) {
                return;
            }
            event = (MouseEvent) e;
            if (event.getID() == MouseEvent.MOUSE_PRESSED) {
                if (event.getComponent() != null && event.getComponent().isShowing()) {
                    if (!isPointInComponent(event.getLocationOnScreen(), toolTipWindow))
                        hideTooltip();
                } else
                    hideTooltip();
            }
        }
    }, AWTEvent.MOUSE_EVENT_MASK);
}

From source file:TransferableScribblePane.java

public TransferableScribblePane() {
    setPreferredSize(new Dimension(450, 200)); // We need a default size
    setBorder(normalBorder); // and a border.
    lines = new ArrayList(); // Start with an empty list of lines

    // Register interest in mouse button and mouse motion events.
    enableEvents(AWTEvent.MOUSE_EVENT_MASK | AWTEvent.MOUSE_MOTION_EVENT_MASK);

    // Enable drag-and-drop by specifying a listener that will be
    // notified when a drag begins. dragGestureListener is defined later.
    DragSource dragSource = DragSource.getDefaultDragSource();
    dragSource.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_COPY_OR_MOVE, dragGestureListener);

    // Enable drops on this component by registering a listener to
    // be notified when something is dragged or dropped over us.
    this.setDropTarget(new DropTarget(this, dropTargetListener));

    // Check whether the system allows us to drag an image of the line
    canDragImage = dragSource.isDragImageSupported();
}