Example usage for java.awt.event MouseEvent MOUSE_ENTERED

List of usage examples for java.awt.event MouseEvent MOUSE_ENTERED

Introduction

In this page you can find the example usage for java.awt.event MouseEvent MOUSE_ENTERED.

Prototype

int MOUSE_ENTERED

To view the source code for java.awt.event MouseEvent MOUSE_ENTERED.

Click Source Link

Document

The "mouse entered" event.

Usage

From source file:Main.java

/**
 * Display mouse events that don't involve mouse motion. The mousemods()
 * method prints modifiers, and is defined below. The other methods return
 * additional information about the mouse event. showLine() displays a line
 * of text in the window. It is defined at the end of this class, along with
 * the paintComponent() method.//from w w w.  ja  va2s.  co m
 */
public void processMouseEvent(MouseEvent e) {
    String type = null;
    switch (e.getID()) {
    case MouseEvent.MOUSE_DRAGGED:
        type = "MOUSE_DRAGGED";
        break;
    case MouseEvent.MOUSE_RELEASED:
        type = "MOUSE_RELEASED";
        break;
    case MouseEvent.MOUSE_CLICKED:
        type = "MOUSE_CLICKED";
        break;
    case MouseEvent.MOUSE_ENTERED:
        type = "MOUSE_ENTERED";
        break;
    case MouseEvent.MOUSE_EXITED:
        type = "MOUSE_EXITED";
        break;
    }
    showLine(mousemods(e) + type + ": [" + e.getX() + "," + e.getY() + "] " + "num clicks = "
            + e.getClickCount() + (e.isPopupTrigger() ? "; is popup trigger" : ""));

    // When the mouse enters the component, request keyboard focus so
    // we can receive and respond to keyboard events
    if (e.getID() == MouseEvent.MOUSE_ENTERED)
        requestFocus();
}

From source file:EventTestPane.java

/**
 * Display mouse events that don't involve mouse motion. The mousemods()
 * method prints modifiers, and is defined below. The other methods return
 * additional information about the mouse event. showLine() displays a line
 * of text in the window. It is defined at the end of this class, along with
 * the paintComponent() method.//ww  w . j ava 2s  . c o  m
 */
public void processMouseEvent(MouseEvent e) {
    String type = null;
    switch (e.getID()) {
    case MouseEvent.MOUSE_PRESSED:
        type = "MOUSE_PRESSED";
        break;
    case MouseEvent.MOUSE_RELEASED:
        type = "MOUSE_RELEASED";
        break;
    case MouseEvent.MOUSE_CLICKED:
        type = "MOUSE_CLICKED";
        break;
    case MouseEvent.MOUSE_ENTERED:
        type = "MOUSE_ENTERED";
        break;
    case MouseEvent.MOUSE_EXITED:
        type = "MOUSE_EXITED";
        break;
    }
    showLine(mousemods(e) + type + ": [" + e.getX() + "," + e.getY() + "] " + "num clicks = "
            + e.getClickCount() + (e.isPopupTrigger() ? "; is popup trigger" : ""));

    // When the mouse enters the component, request keyboard focus so
    // we can receive and respond to keyboard events
    if (e.getID() == MouseEvent.MOUSE_ENTERED)
        requestFocus();
}

From source file:Diva.java

@Override
protected void processMouseEvent(MouseEvent e, JLayer l) {
    if (e.getID() == MouseEvent.MOUSE_ENTERED)
        mActive = true;//  w  w w  .  j  a v a  2  s.c  o  m
    if (e.getID() == MouseEvent.MOUSE_EXITED)
        mActive = false;
    l.repaint();
}

From source file:AppletMenuBarDemo.java

/** Called when a mouse event happens over the menubar */
protected void processMouseEvent(MouseEvent e) {
    int type = e.getID(); // What type of event?
    int item = findItemAt(e.getX()); // Over which menu label?

    if (type == MouseEvent.MOUSE_PRESSED) {
        // If it was a mouse down event, then pop up the menu
        if (item == -1)
            return;
        Dimension size = getSize();
        PopupMenu pm = (PopupMenu) menus.elementAt(item);
        if (pm != null)
            pm.show(this, startPositions[item] - 3, size.height);

    } else if (type == MouseEvent.MOUSE_EXITED) {
        // If the mouse left the menubar, then unhighlight
        if (highlightedItem != -1) {
            highlightedItem = -1;/* ww  w. j av  a 2 s . co  m*/
            if (highlightColor != null)
                repaint();
        }
    } else if ((type == MouseEvent.MOUSE_MOVED) || (type == MouseEvent.MOUSE_ENTERED)) {
        // If the mouse moved, change the highlighted item, if necessary
        if (item != highlightedItem) {
            highlightedItem = item;
            if (highlightColor != null)
                repaint();
        }
    }
}

From source file:net.sourceforge.squirrel_sql.fw.gui.debug.DebugEventListener.java

public void eventDispatched(AWTEvent event) {
    Object o = event.getSource();
    if (o instanceof JComponent && o != null) {
        JComponent source = (JComponent) o;
        switch (event.getID()) {
        case MouseEvent.MOUSE_DRAGGED:
            printDebugInfo(source, event);
            break;
        case MouseEvent.MOUSE_ENTERED:
            printDebugInfo(source, event);
            setToolTipText(source, event);
            setBorder(source, event);/*from   www  .  j a  va 2 s . c  o  m*/
            break;
        case MouseEvent.MOUSE_EXITED:
            printDebugInfo(source, event);
            setBorder(source, event);
            break;
        }
    }
}

From source file:net.sourceforge.squirrel_sql.fw.gui.debug.DebugEventListener.java

private void setBorder(JComponent source, AWTEvent event) {
    Border border = source.getBorder();
    switch (event.getID()) {
    case MouseEvent.MOUSE_ENTERED:
        if (border != null) {
            source.setBorder(new DebugBorder(border));
        }//from ww  w. j a  v  a 2s  .  c o m
        break;
    case MouseEvent.MOUSE_EXITED:
        if (border != null && border instanceof DebugBorder) {
            source.setBorder(((DebugBorder) border).getDelegate());
        }
        break;
    }
}

From source file:net.sourceforge.squirrel_sql.fw.gui.debug.DebugEventListener.java

private String getEventMessagePrefix(AWTEvent event) {
    String result = null;/*from w ww  .  j  a  v a 2  s . c  o  m*/
    switch (event.getID()) {
    case MouseEvent.MOUSE_DRAGGED:
        result = "Mouse dragged: ";
        break;
    case MouseEvent.MOUSE_ENTERED:
        result = "Mouse entered: ";
        break;
    case MouseEvent.MOUSE_EXITED:
        result = "Mouse exited: ";
        break;
    default:
        result = "Unknown EventType: ";
    }
    return result;
}

From source file:thesaurusEditor.gui.graph.MainGraph.java

protected void processMouseEvent(MouseEvent e) {
    if (e.getID() == MouseEvent.MOUSE_ENTERED) {
        this.requestFocus();
    }
}