在java中检测水平鼠标滚轮移动

时间:2014-05-09 13:45:06

标签: java swing button mouse listener

Java无法检测到这两个按钮有什么特别的原因吗? http://i.stack.imgur.com/Oggsj.png

我写了一个简单的类来检查这些按钮。

import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.JFrame;

public class Horizontal_wheel_button_test
{
    public static void main (String [] args) throws Exception
    {
        JFrame okno = new JFrame ();
        okno.setSize (800, 600);
        okno.setVisible (true);
        okno.setLocationRelativeTo (null);
        okno.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
        okno.addMouseListener (new MouseListener ()
        {
            @Override
            public void mouseReleased (MouseEvent e)
            {
            }
            @Override
            public void mousePressed (MouseEvent e)
            {
                System.out.println (e);
            }
            @Override
            public void mouseExited (MouseEvent e)
            {
            }
            @Override
            public void mouseEntered (MouseEvent e)
            {
            }
            @Override
            public void mouseClicked (MouseEvent e)
            {
                System.out.println (e);
            }
        });
    }
}

当我按下标准按钮时,Listener会做出反应,给我1到3个按钮的数量,但是当我向左和向右按下滚轮时,它无法通知这些事件。是因为Java不支持这些按钮,也可能是因为我的操作系统(Windows 7)?

0 个答案:

没有答案