Example usage for java.awt AWTEvent MOUSE_MOTION_EVENT_MASK

List of usage examples for java.awt AWTEvent MOUSE_MOTION_EVENT_MASK

Introduction

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

Prototype

long MOUSE_MOTION_EVENT_MASK

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

Click Source Link

Document

The event mask for selecting mouse motion events.

Usage

From source file:Main.java

/** The constructor: register the event types we are interested in */
public Main() {/*from www.  j ava 2  s  .  c om*/
    // 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  av  a  2 s .  c om
    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  w  w  . j a  va  2 s  .com
 */
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: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();
}

From source file:com.hp.alm.ali.idea.content.taskboard.TaskBoardPanel.java

public TaskBoardPanel(final Project project) {
    super(new BorderLayout());

    this.project = project;

    status = new EntityStatusPanel(project);
    queue = new QueryQueue(project, status, false);

    entityService = project.getComponent(EntityService.class);
    entityService.addEntityListener(this);
    sprintService = project.getComponent(SprintService.class);
    sprintService.addListener(this);

    loadTasks();//from   w  w  w  .j  a  v  a 2  s. c o m

    header = new Header();
    columnHeader = new ColumnHeader();

    content = new Content();
    add(content, BorderLayout.NORTH);

    header.assignedTo.reload();

    // force mouse-over task as visible (otherwise events are captured by the overlay and repaint quirks)
    Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
        @Override
        public void eventDispatched(AWTEvent event) {
            if (isShowing() && event.getID() == MouseEvent.MOUSE_MOVED) {
                MouseEvent m = (MouseEvent) event;
                TaskPanel currentPanel = locateContainer(m, TaskPanel.class);
                if (currentPanel != null) {
                    if (forcedTaskPanel == currentPanel) {
                        return;
                    } else if (forcedTaskPanel != null) {
                        forcedTaskPanel.removeForcedMatch(this);
                    }
                    forcedTaskPanel = currentPanel;
                    forcedTaskPanel.addForcedMatch(this);
                } else if (forcedTaskPanel != null) {
                    forcedTaskPanel.removeForcedMatch(this);
                    forcedTaskPanel = null;
                }
            }
        }
    }, AWTEvent.MOUSE_MOTION_EVENT_MASK);

    Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
        @Override
        public void eventDispatched(AWTEvent event) {
            if (isShowing()) {
                MouseEvent m = (MouseEvent) event;
                switch (event.getID()) {
                case MouseEvent.MOUSE_PRESSED:
                case MouseEvent.MOUSE_RELEASED:
                    // implement backlog item popup
                    if (m.isPopupTrigger()) {
                        final BacklogItemPanel itemPanel = locateContainer(m, BacklogItemPanel.class);
                        if (itemPanel != null) {
                            ActionPopupMenu popupMenu = ActionUtil.createEntityActionPopup("taskboard");
                            Point p = SwingUtilities.convertPoint(m.getComponent(), m.getPoint(), itemPanel);
                            popupMenu.getComponent().show(itemPanel, p.x, p.y);
                        }
                    }
                    break;

                case MouseEvent.MOUSE_CLICKED:
                    // implement backlog item double click
                    if (m.getClickCount() > 1) {
                        BacklogItemPanel itemPanel = locateContainer(m, BacklogItemPanel.class);
                        if (itemPanel != null) {
                            Entity backlogItem = itemPanel.getItem();
                            Entity workItem = new Entity(backlogItem.getPropertyValue("entity-type"),
                                    Integer.valueOf(backlogItem.getPropertyValue("entity-id")));
                            AliContentFactory.loadDetail(project, workItem, true, true);
                        }
                    }
                }
            }

        }
    }, AWTEvent.MOUSE_EVENT_MASK);
}

From source file:org.gvsig.remotesensing.scatterplot.chart.ScatterPlotDiagram.java

/**
 * Constructs a JFreeChart panel./*from w  w w  .j a  v  a2  s .co  m*/
 *
 * @param chart  the chart.
 * @param width  the preferred width of the panel.
 * @param height  the preferred height of the panel.
 * @param minimumDrawWidth  the minimum drawing width.
 * @param minimumDrawHeight  the minimum drawing height.
 * @param maximumDrawWidth  the maximum drawing width.
 * @param maximumDrawHeight  the maximum drawing height.
 * @param useBuffer  a flag that indicates whether to use the off-screen
 *                   buffer to improve performance (at the expense of 
 *                   memory).
 * @param properties  a flag indicating whether or not the chart property
 *                    editor should be available via the popup menu.
 * @param save  a flag indicating whether or not save options should be
 *              available via the popup menu.
 * @param print  a flag indicating whether or not the print option
 *               should be available via the popup menu.
 * @param zoom  a flag indicating whether or not zoom options should be 
 *              added to the popup menu.
 * @param tooltips  a flag indicating whether or not tooltips should be 
 *                  enabled for the chart.
 */
public ScatterPlotDiagram(JFreeChart chart, int width, int height, int minimumDrawWidth, int minimumDrawHeight,
        int maximumDrawWidth, int maximumDrawHeight, boolean useBuffer, boolean properties, boolean save,
        boolean print, boolean zoom, boolean tooltips) {

    this.setChart(chart);
    this.chartMouseListeners = new EventListenerList();
    this.info = new ChartRenderingInfo();
    setPreferredSize(new Dimension(width, height));
    this.useBuffer = useBuffer;
    this.refreshBuffer = false;
    this.minimumDrawWidth = minimumDrawWidth;
    this.minimumDrawHeight = minimumDrawHeight;
    this.maximumDrawWidth = maximumDrawWidth;
    this.maximumDrawHeight = maximumDrawHeight;
    this.zoomTriggerDistance = DEFAULT_ZOOM_TRIGGER_DISTANCE;

    this.popup = null;
    if (properties || save || print || zoom) {
        this.popup = createPopupMenu(properties, save, print, zoom);
    }

    enableEvents(AWTEvent.MOUSE_EVENT_MASK);
    enableEvents(AWTEvent.MOUSE_MOTION_EVENT_MASK);
    setDisplayToolTips(tooltips);
    addMouseListener(this);
    addMouseMotionListener(this);

    this.defaultDirectoryForSaveAs = null;
    this.enforceFileExtensions = true;

}

From source file:com.projity.contrib.calendar.JXXMonthView.java

/**
 * Create a new instance of the <code>JXMonthView</code> class using the
 * month and year from <code>initialTime</code> as the first date to
 * display.// w  ww.j a  v a2  s.co  m
 *
 * @param initialTime
 *            The first month to display.
 */
public JXXMonthView(long initialTime) {
    super();

    _ltr = getComponentOrientation().isLeftToRight();

    // Set up calendar instance.
    _cal = calendarInstance(); //PROJITY_MODIFICATION
    _cal.setFirstDayOfWeek(_firstDayOfWeek);
    _cal.setMinimalDaysInFirstWeek(1); //PROJITY_MODIFICATION // needed for weeks with less than 3 days so that they start on week 1 instead of week 0

    // Keep track of today.
    _cal.set(Calendar.HOUR_OF_DAY, 0);
    _cal.set(Calendar.MINUTE, 0);
    _cal.set(Calendar.SECOND, 0);
    _cal.set(Calendar.MILLISECOND, 0);
    _today = _cal.getTimeInMillis();

    _cal.setTimeInMillis(initialTime);
    setFirstDisplayedDate(_cal.getTimeInMillis());

    // Get string representation of the months of the year.
    _cal.set(Calendar.MONTH, _cal.getMinimum(Calendar.MONTH));
    _cal.set(Calendar.DAY_OF_MONTH, _cal.getActualMinimum(Calendar.DAY_OF_MONTH));
    _monthsOfTheYear = new String[MONTHS_IN_YEAR];
    SimpleDateFormat fullMonthNameFormatter = dateFormatInstance("MMMM");
    for (int i = 0; i < MONTHS_IN_YEAR; i++) {
        _monthsOfTheYear[i] = fullMonthNameFormatter.format(_cal.getTime());
        _cal.add(Calendar.MONTH, 1);
    }

    setOpaque(true);
    setBackground(Color.WHITE);
    setFont(new Font("Dialog", Font.PLAIN, 12));
    _todayBackgroundColor = getForeground();

    // Restore original time value.
    _cal.setTimeInMillis(_firstDisplayedDate);

    enableEvents(AWTEvent.MOUSE_EVENT_MASK);
    enableEvents(AWTEvent.MOUSE_MOTION_EVENT_MASK);

    updateUI();
}