Example usage for java.awt.event MouseEvent getComponent

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

Introduction

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

Prototype

public Component getComponent() 

Source Link

Document

Returns the originator of the event.

Usage

From source file:MyButtonUI.java

public void mousePressed(MouseEvent e) {
    JComponent c = (JComponent) e.getComponent();
    c.setBorder(m_borderLowered);/*from   w ww .j ava  2  s  .  c o  m*/
    c.setBackground(m_backgroundPressed);
}

From source file:MyButtonUI.java

public void mouseReleased(MouseEvent e) {
    JComponent c = (JComponent) e.getComponent();
    c.setBorder(m_borderRaised);/*from  w  w w  .j ava 2 s . co m*/
    c.setBackground(m_backgroundNormal);
}

From source file:MyButtonUI.java

public void mouseEntered(MouseEvent e) {
    JComponent c = (JComponent) e.getComponent();
    c.setForeground(m_foregroundActive);
    c.repaint();
}

From source file:MyButtonUI.java

public void mouseExited(MouseEvent e) {
    JComponent c = (JComponent) e.getComponent();
    c.setForeground(m_foregroundNormal);
    c.repaint();
}

From source file:facebookchat.ui.common.JNABalloon.java

private void hidePopup(MouseEvent e) {
    e.getComponent().removeMouseListener(listener);
    if (popup != null)
        popup.hide();
}

From source file:events.MouseEventDemo.java

void eventOutput(String eventDescription, MouseEvent e) {
    textArea.append(eventDescription + " detected on " + e.getComponent().getClass().getName() + "." + NEWLINE);
    textArea.setCaretPosition(textArea.getDocument().getLength());
}

From source file:Diva.java

@Override
protected void processMouseMotionEvent(MouseEvent e, JLayer l) {
    Point p = SwingUtilities.convertPoint(e.getComponent(), e.getPoint(), l);
    mX = p.x;/*from  w w  w .  j  av a2 s.  c  o m*/
    mY = p.y;
    l.repaint();
}

From source file:MouseEventDemo.java

void saySomething(String eventDescription, MouseEvent e) {
    textArea.append(eventDescription + " detected on " + e.getComponent().getClass().getName() + "." + newline);
    textArea.setCaretPosition(textArea.getDocument().getLength());
}

From source file:de.weltraumschaf.minesweeper.control.FieldBoxButtonListener.java

@Override
public void mouseClicked(final MouseEvent e) {
    if (!(e.getComponent() instanceof FieldBoxButton)) {
        LOG.warn("Got click event from something else than FieldBoxButton!");
        return;/*from ww  w . j  a  va 2s .  co m*/
    }

    final FieldBoxButton originatingButton = (FieldBoxButton) e.getComponent();

    if (originatingButton.isOpen()) {
        LOG.debug(String.format("Button %s already opened, exit.", originatingButton));
        return;
    }

    if (SwingUtilities.isRightMouseButton(e)) {
        LOG.debug(String.format("Right click on %s.", originatingButton.getBox()));

        if (originatingButton.isFlag()) {
            originatingButton.close();
        } else {
            originatingButton.flag();
        }
    } else {
        LOG.debug(String.format("Left click on %s", originatingButton.getBox()));

        if (originatingButton.isFlag()) {
            LOG.debug(String.format("Button %s flagged, exit.", originatingButton));
            return;
        }

        originatingButton.open();
    }

    originatingButton.getParent().repaint();
    main.getStatusbar().setMinesLeft(originatingButton.getBox().getField().countUnflaggedMines());
    checkForWon(originatingButton.getBox().getField());
}

From source file:events.MouseMotionEventDemo.java

void eventOutput(String eventDescription, MouseEvent e) {
    textArea.append(eventDescription + " (" + e.getX() + "," + e.getY() + ")" + " detected on "
            + e.getComponent().getClass().getName() + NEWLINE);
    textArea.setCaretPosition(textArea.getDocument().getLength());
}