本文整理汇总了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);
}
示例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);
}
示例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;
}
}
示例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;
}
}