Example usage for java.awt AWTEvent getID

List of usage examples for java.awt AWTEvent getID

Introduction

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

Prototype

public int getID() 

Source Link

Document

Returns the event type.

Usage

From source file:Main.java

public static boolean isPasteAction() {
    AWTEvent e = EventQueue.getCurrentEvent();
    if (e != null && e.getID() == KeyEvent.KEY_PRESSED) {
        KeyEvent k = (KeyEvent) e;
        if (k.getKeyCode() == KeyEvent.VK_V && k.getModifiers() == KeyEvent.CTRL_MASK) {
            return true;
        }/*from ww w  .  j a va  2 s  .c  om*/
    }
    return false;
}

From source file:Main.java

public void eventDispatched(AWTEvent evt) {
    if (evt.getID() == WindowEvent.WINDOW_OPENED) {
        ComponentEvent cev = (ComponentEvent) evt;
        if (cev.getComponent() instanceof JFrame) {
            System.out.println("event: " + evt);
            JFrame frame = (JFrame) cev.getComponent();
            loadSettings(frame);//from www .j  av a2 s  .  c o  m
        }
    }
}

From source file:ItemEventComponent.java

public void processEvent(AWTEvent e) {
    if (e.getID() == MouseEvent.MOUSE_PRESSED) {
        if (itemListener != null) {
            selected = !selected;//from  ww w  . ja  v  a  2s  .  c  o m
            i++;
            itemListener.itemStateChanged(new ItemEvent(this, ItemEvent.ITEM_STATE_CHANGED,
                    getSelectedObjects(), (selected ? ItemEvent.SELECTED : ItemEvent.DESELECTED)));
        }
    }
}

From source file:Main.java

public Point getClick() {
    EventQueue eq = Toolkit.getDefaultToolkit().getSystemEventQueue();
    while (true) {
        try {//from ww w  . j  a v  a  2  s  .c  o m
            AWTEvent evt = eq.getNextEvent();
            if (evt.getID() == MouseEvent.MOUSE_PRESSED) {
                MouseEvent mevt = (MouseEvent) evt;
                Point p = mevt.getPoint();
                Point top = getRootPane().getLocation();
                p.x -= top.x;
                p.y -= top.y;
                return p;
            }
        } catch (InterruptedException e) {
        }
    }
}

From source file:Main.java

public Point getClick() {
    EventQueue eq = Toolkit.getDefaultToolkit().getSystemEventQueue();
    System.out.println(eq.isDispatchThread());
    while (true) {
        try {/* w  w w  .j  a va  2  s .  com*/
            AWTEvent evt = eq.getNextEvent();
            if (evt.getID() == MouseEvent.MOUSE_PRESSED) {
                MouseEvent mevt = (MouseEvent) evt;
                Point p = mevt.getPoint();
                Point top = getRootPane().getLocation();
                p.x -= top.x;
                p.y -= top.y;
                return p;
            }
        } catch (InterruptedException e) {
        }
    }
}

From source file:Main.java

public Point getClick() {
    EventQueue eq = Toolkit.getDefaultToolkit().getSystemEventQueue();

    while (true) {
        try {/* w w w  .  jav a  2 s .  com*/
            AWTEvent pEvent = eq.peekEvent();

            AWTEvent evt = eq.getNextEvent();
            if (evt.getID() == MouseEvent.MOUSE_PRESSED) {
                MouseEvent mevt = (MouseEvent) evt;
                Point p = mevt.getPoint();
                Point top = getRootPane().getLocation();
                p.x -= top.x;
                p.y -= top.y;
                return p;
            }
        } catch (InterruptedException e) {
        }
    }
}

From source file:SimpleInputMethod.java

public void dispatchEvent(AWTEvent event) {
    if (event.getID() == KeyEvent.KEY_TYPED) {
        KeyEvent e = (KeyEvent) event;
        if (handleCharacter(e.getKeyChar())) {
            e.consume();//from   w  w  w  .  ja v  a  2  s . c  om
        }
    }
}

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

private String getEventMessagePrefix(AWTEvent event) {
    String result = null;/*w ww . j a v  a2  s . c om*/
    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: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  www. j  a v  a2  s  .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

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 2s . c  om
            break;
        case MouseEvent.MOUSE_EXITED:
            printDebugInfo(source, event);
            setBorder(source, event);
            break;
        }
    }
}