List of usage examples for java.awt AWTEvent MOUSE_WHEEL_EVENT_MASK
long MOUSE_WHEEL_EVENT_MASK
To view the source code for java.awt AWTEvent MOUSE_WHEEL_EVENT_MASK.
Click Source Link
From source file:Main.java
public Main() { label = new JLabel("Waiting..."); frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(label);/*w w w . j a va2 s . co 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(); }