当前位置: 首页>>代码示例>>Java>>正文


Java SunToolkit.getNumberOfButtons方法代码示例

本文整理汇总了Java中sun.awt.SunToolkit.getNumberOfButtons方法的典型用法代码示例。如果您正苦于以下问题:Java SunToolkit.getNumberOfButtons方法的具体用法?Java SunToolkit.getNumberOfButtons怎么用?Java SunToolkit.getNumberOfButtons使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sun.awt.SunToolkit的用法示例。


在下文中一共展示了SunToolkit.getNumberOfButtons方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleMouseEvent

import sun.awt.SunToolkit; //导入方法依赖的package包/类
/**
 * Handles mouse events.
 */
void handleMouseEvent(int eventType, int modifierFlags, int buttonNumber,
                      int clickCount, int x, int y, int absoluteX,
                      int absoluteY) {
    final SunToolkit tk = (SunToolkit)Toolkit.getDefaultToolkit();
    if ((buttonNumber > 2 && !tk.areExtraMouseButtonsEnabled())
            || buttonNumber > tk.getNumberOfButtons() - 1) {
        return;
    }

    int jeventType = isNpapiCallback ? NSEvent.npToJavaEventType(eventType) :
                                       NSEvent.nsToJavaEventType(eventType);

    int jbuttonNumber = MouseEvent.NOBUTTON;
    int jclickCount = 0;

    if (jeventType != MouseEvent.MOUSE_MOVED &&
        jeventType != MouseEvent.MOUSE_ENTERED &&
        jeventType != MouseEvent.MOUSE_EXITED)
    {
        jbuttonNumber = NSEvent.nsToJavaButton(buttonNumber);
        jclickCount = clickCount;
    }

    int jmodifiers = NSEvent.nsToJavaMouseModifiers(buttonNumber,
                                                    modifierFlags);
    boolean jpopupTrigger = NSEvent.isPopupTrigger(jmodifiers);

    eventNotifier.notifyMouseEvent(jeventType, System.currentTimeMillis(), jbuttonNumber,
            x, y, absoluteX, absoluteY, jmodifiers, jclickCount,
            jpopupTrigger, null);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:35,代码来源:CPlatformResponder.java

示例2: handleMouseEvent

import sun.awt.SunToolkit; //导入方法依赖的package包/类
/**
 * Handles mouse events.
 */
void handleMouseEvent(int eventType, int modifierFlags, int buttonNumber,
                      int clickCount, int x, int y, int absX, int absY) {
    final SunToolkit tk = (SunToolkit)Toolkit.getDefaultToolkit();
    if ((buttonNumber > 2 && !tk.areExtraMouseButtonsEnabled())
            || buttonNumber > tk.getNumberOfButtons() - 1) {
        return;
    }

    int jeventType = isNpapiCallback ? NSEvent.npToJavaEventType(eventType) :
                                       NSEvent.nsToJavaEventType(eventType);

    int jbuttonNumber = MouseEvent.NOBUTTON;
    int jclickCount = 0;

    if (jeventType != MouseEvent.MOUSE_MOVED &&
        jeventType != MouseEvent.MOUSE_ENTERED &&
        jeventType != MouseEvent.MOUSE_EXITED)
    {
        jbuttonNumber = NSEvent.nsToJavaButton(buttonNumber);
        jclickCount = clickCount;
    }

    int jmodifiers = NSEvent.nsToJavaModifiers(modifierFlags);
    boolean jpopupTrigger = NSEvent.isPopupTrigger(jmodifiers);

    eventNotifier.notifyMouseEvent(jeventType, System.currentTimeMillis(), jbuttonNumber,
            x, y, absX, absY, jmodifiers, jclickCount,
            jpopupTrigger, null);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:33,代码来源:CPlatformResponder.java

示例3: handleMouseEvent

import sun.awt.SunToolkit; //导入方法依赖的package包/类
private void handleMouseEvent(NSEvent nsEvent) {
    int buttonNumber = nsEvent.getButtonNumber();
    final SunToolkit tk = (SunToolkit)Toolkit.getDefaultToolkit();
    if ((buttonNumber > 2 && !tk.areExtraMouseButtonsEnabled())
            || buttonNumber > tk.getNumberOfButtons() - 1) {
        return;
    }

    int jeventType = NSEvent.nsToJavaEventType(nsEvent.getType());

    int jbuttonNumber = MouseEvent.NOBUTTON;
    int jclickCount = 0;
    if (jeventType != MouseEvent.MOUSE_MOVED) {
        jbuttonNumber = NSEvent.nsToJavaButton(buttonNumber);
        jclickCount = nsEvent.getClickCount();
    }

    int jmodifiers = NSEvent.nsToJavaMouseModifiers(buttonNumber,
            nsEvent.getModifierFlags());
    boolean isPopupTrigger = NSEvent.isPopupTrigger(jmodifiers);

    int eventButtonMask = (jbuttonNumber > 0)?
            MouseEvent.getMaskForButton(jbuttonNumber) : 0;
    long when = System.currentTimeMillis();

    if (jeventType == MouseEvent.MOUSE_PRESSED) {
        mouseClickButtons |= eventButtonMask;
    } else if (jeventType == MouseEvent.MOUSE_DRAGGED) {
        mouseClickButtons = 0;
    }

    // The MouseEvent's coordinates are relative to screen
    int absX = nsEvent.getAbsX();
    int absY = nsEvent.getAbsY();

    MouseEvent mouseEvent = new MouseEvent(dummyFrame, jeventType, when,
            jmodifiers, absX, absY, absX, absY, jclickCount, isPopupTrigger,
            jbuttonNumber);
    mouseEvent.setSource(target);
    postEvent(mouseEvent);

    // fire ACTION event
    if (jeventType == MouseEvent.MOUSE_PRESSED && isPopupTrigger) {
        final String cmd = target.getActionCommand();
        final ActionEvent event = new ActionEvent(target,
                ActionEvent.ACTION_PERFORMED, cmd);
        postEvent(event);
    }

    // synthesize CLICKED event
    if (jeventType == MouseEvent.MOUSE_RELEASED) {
        if ((mouseClickButtons & eventButtonMask) != 0) {
            MouseEvent clickEvent = new MouseEvent(dummyFrame,
                    MouseEvent.MOUSE_CLICKED, when, jmodifiers, absX, absY,
                    absX, absY, jclickCount, isPopupTrigger, jbuttonNumber);
            clickEvent.setSource(target);
            postEvent(clickEvent);
        }

        mouseClickButtons &= ~eventButtonMask;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:63,代码来源:CTrayIcon.java

示例4: handleMouseEvent

import sun.awt.SunToolkit; //导入方法依赖的package包/类
private void handleMouseEvent(NSEvent nsEvent) {
    int buttonNumber = nsEvent.getButtonNumber();
    final SunToolkit tk = (SunToolkit)Toolkit.getDefaultToolkit();
    if ((buttonNumber > 2 && !tk.areExtraMouseButtonsEnabled())
            || buttonNumber > tk.getNumberOfButtons() - 1) {
        return;
    }

    int jeventType = NSEvent.nsToJavaEventType(nsEvent.getType());

    int jbuttonNumber = MouseEvent.NOBUTTON;
    int jclickCount = 0;
    if (jeventType != MouseEvent.MOUSE_MOVED) {
        jbuttonNumber = NSEvent.nsToJavaButton(buttonNumber);
        jclickCount = nsEvent.getClickCount();
    }

    int jmodifiers = NSEvent.nsToJavaModifiers(
            nsEvent.getModifierFlags());
    boolean isPopupTrigger = NSEvent.isPopupTrigger(jmodifiers);

    int eventButtonMask = (jbuttonNumber > 0)?
            MouseEvent.getMaskForButton(jbuttonNumber) : 0;
    long when = System.currentTimeMillis();

    if (jeventType == MouseEvent.MOUSE_PRESSED) {
        mouseClickButtons |= eventButtonMask;
    } else if (jeventType == MouseEvent.MOUSE_DRAGGED) {
        mouseClickButtons = 0;
    }

    // The MouseEvent's coordinates are relative to screen
    int absX = nsEvent.getAbsX();
    int absY = nsEvent.getAbsY();

    MouseEvent mouseEvent = new MouseEvent(dummyFrame, jeventType, when,
            jmodifiers, absX, absY, absX, absY, jclickCount, isPopupTrigger,
            jbuttonNumber);
    mouseEvent.setSource(target);
    postEvent(mouseEvent);

    // fire ACTION event
    if (jeventType == MouseEvent.MOUSE_PRESSED && isPopupTrigger) {
        final String cmd = target.getActionCommand();
        final ActionEvent event = new ActionEvent(target,
                ActionEvent.ACTION_PERFORMED, cmd);
        postEvent(event);
    }

    // synthesize CLICKED event
    if (jeventType == MouseEvent.MOUSE_RELEASED) {
        if ((mouseClickButtons & eventButtonMask) != 0) {
            MouseEvent clickEvent = new MouseEvent(dummyFrame,
                    MouseEvent.MOUSE_CLICKED, when, jmodifiers, absX, absY,
                    absX, absY, jclickCount, isPopupTrigger, jbuttonNumber);
            clickEvent.setSource(target);
            postEvent(clickEvent);
        }

        mouseClickButtons &= ~eventButtonMask;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:63,代码来源:CTrayIcon.java


注:本文中的sun.awt.SunToolkit.getNumberOfButtons方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。