本文整理汇总了Java中java.awt.event.MouseEvent.MOUSE_DRAGGED属性的典型用法代码示例。如果您正苦于以下问题:Java MouseEvent.MOUSE_DRAGGED属性的具体用法?Java MouseEvent.MOUSE_DRAGGED怎么用?Java MouseEvent.MOUSE_DRAGGED使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类java.awt.event.MouseEvent
的用法示例。
在下文中一共展示了MouseEvent.MOUSE_DRAGGED属性的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: draggedGeneratesSameEvents
public void draggedGeneratesSameEvents() throws Throwable {
events = MouseEvent.MOUSE_DRAGGED;
SwingUtilities.invokeAndWait(new Runnable() {
@Override public void run() {
actionsArea.setText("");
}
});
driver = new JavaDriver();
WebElement b = driver.findElement(By.name("click-me"));
WebElement t = driver.findElement(By.name("actions"));
Point location = EventQueueWait.call_noexc(button, "getLocationOnScreen");
Dimension size = EventQueueWait.call_noexc(button, "getSize");
Robot r = new Robot();
r.setAutoDelay(10);
r.setAutoWaitForIdle(true);
Point location2 = EventQueueWait.call_noexc(actionsArea, "getLocationOnScreen");
Dimension size2 = EventQueueWait.call_noexc(actionsArea, "getSize");
r.mouseMove(location.x + size.width / 2, location.y + size.height / 2);
r.mousePress(InputEvent.BUTTON1_MASK);
r.mouseMove(location2.x + size2.width / 2, location2.y + size2.height / 2);
r.mouseRelease(InputEvent.BUTTON1_MASK);
new EventQueueWait() {
@Override public boolean till() {
return actionsArea.getText().length() > 0;
}
}.wait("Waiting for actionsArea failed?");
String expected = t.getText();
tclear();
r.mousePress(InputEvent.BUTTON1_MASK);
r.mouseRelease(InputEvent.BUTTON1_MASK);
b.click();
tclear();
System.err.println("============================");
new Actions(driver).clickAndHold(b).moveToElement(b).release().perform();
System.err.println("============================");
AssertJUnit.assertEquals(expected, t.getText());
}
示例2: eventDispatched
@Override
public void eventDispatched(AWTEvent e) {
if (e instanceof MouseEvent) {
MouseEvent me = (MouseEvent) e;
if (!SwingUtilities.isDescendingFrom(me.getComponent(), target)) {
return;
}
if (me.getID() == MouseEvent.MOUSE_RELEASED) {
// stop when mouse released
mouseOnScreenPoint = null;
if (timer.isRunning()) {
timer.stop();
}
} else if (me.getID() == MouseEvent.MOUSE_DRAGGED && me.getComponent() == target) {
mouseOnScreenPoint = me.getLocationOnScreen();
} else if (me.getID() == MouseEvent.MOUSE_PRESSED && me.getComponent() == target) {
mouseOnScreenPoint = me.getLocationOnScreen();
timer.start();
}
}
}
示例3: isRightMouseButton
static boolean isRightMouseButton(MouseEvent me) {
int numButtons = ((Integer)getDefaultToolkit().getDesktopProperty("awt.mouse.numButtons")).intValue();
switch (me.getID()) {
case MouseEvent.MOUSE_PRESSED:
case MouseEvent.MOUSE_RELEASED:
return ((numButtons == 2 && me.getButton() == MouseEvent.BUTTON2) ||
(numButtons > 2 && me.getButton() == MouseEvent.BUTTON3));
case MouseEvent.MOUSE_ENTERED:
case MouseEvent.MOUSE_EXITED:
case MouseEvent.MOUSE_CLICKED:
case MouseEvent.MOUSE_DRAGGED:
return ((numButtons == 2 && (me.getModifiersEx() & InputEvent.BUTTON2_DOWN_MASK) != 0) ||
(numButtons > 2 && (me.getModifiersEx() & InputEvent.BUTTON3_DOWN_MASK) != 0));
}
return false;
}
示例4: redirectMouseEvent
/**
* Redirects the mouse event
* @param evt
* @param listener
*/
private void redirectMouseEvent(MouseEvent evt, ListenerBean listener) {
switch(evt.getID()) {
case MouseEvent.MOUSE_DRAGGED:
listener.listener.mouseDragged(evt);
case MouseEvent.MOUSE_MOVED:
listener.listener.mouseMoved(evt);
}
}
示例5: processMouseEvent
@Override
protected void processMouseEvent(MouseEvent e) {
switch(e.getID()) {
case MouseEvent.MOUSE_PRESSED:
selectionDisabled = false;
break;
case MouseEvent.MOUSE_RELEASED:
selectionDisabled = false;
break;
case MouseEvent.MOUSE_CLICKED:
selectionDisabled = false;
break;
case MouseEvent.MOUSE_ENTERED:
selectionDisabled = false;
break;
case MouseEvent.MOUSE_EXITED:
selectionDisabled = false;
break;
case MouseEvent.MOUSE_MOVED:
break;
case MouseEvent.MOUSE_DRAGGED:
if (selectionDisabled) {
//System.err.println("\nDrag DISABLED.");
return ;
}
break;
case MouseEvent.MOUSE_WHEEL:
break;
}
super.processMouseEvent(e);
}
示例6: moveto
@Override public void moveto(Component component, int xOffset, int yOffset) {
int buttons = deviceState.getButtons();
if (component != deviceState.getComponent()) {
if (deviceState.getComponent() != null) {
dispatchEvent(new MouseEvent(deviceState.getComponent(), MouseEvent.MOUSE_EXITED, System.currentTimeMillis(),
deviceState.getModifierEx(), deviceState.x, deviceState.y, 0, false, buttons));
}
dispatchEvent(new MouseEvent(component, MouseEvent.MOUSE_ENTERED, System.currentTimeMillis(),
deviceState.getModifierEx(), xOffset, yOffset, 0, false, buttons));
}
Component source = component;
int id = MouseEvent.MOUSE_MOVED;
Point p = new Point(xOffset, yOffset);
if (buttons != 0) {
id = MouseEvent.MOUSE_DRAGGED;
source = deviceState.getDragSource();
if (source != component) {
p = SwingUtilities.convertPoint(component, xOffset, yOffset, source);
}
}
int modifierEx = deviceState.getModifierEx() | deviceState.getButtonMask();
MouseEvent mouseEvent = new MouseEvent(source, id, System.currentTimeMillis(), modifierEx, p.x, p.y, 0, false, buttons);
dispatchEvent(mouseEvent);
EventQueueWait.empty();
deviceState.setComponent(component);
deviceState.setMousePosition(xOffset, yOffset);
}
示例7: processEvent
private void processEvent(MouseEvent e, JXLayer layer) {
if (MouseEvent.MOUSE_DRAGGED == e.getID()) {
return;
}
final Point mousePoint = SwingUtilities.convertPoint(e.getComponent(), e.getPoint(), layer);
if (this.updateMainTraceInfo(mousePoint)) {
//this.updateIndicatorTraceInfos(this.mainTraceInfo.getDataIndex());
this.setDirty(true);
}
}
示例8: handleJavaMouseEvent
@Override
public void handleJavaMouseEvent( MouseEvent mouseEvent ) {
super.handleJavaMouseEvent(mouseEvent);
if (xtext != null) {
mouseEvent.setSource(xtext);
int id = mouseEvent.getID();
if (id == MouseEvent.MOUSE_DRAGGED || id == MouseEvent.MOUSE_MOVED)
xtext.processMouseMotionEventImpl(mouseEvent);
else
xtext.processMouseEventImpl(mouseEvent);
}
}
示例9: isLeftMouseButton
static boolean isLeftMouseButton(MouseEvent me) {
switch (me.getID()) {
case MouseEvent.MOUSE_PRESSED:
case MouseEvent.MOUSE_RELEASED:
return (me.getButton() == MouseEvent.BUTTON1);
case MouseEvent.MOUSE_ENTERED:
case MouseEvent.MOUSE_EXITED:
case MouseEvent.MOUSE_CLICKED:
case MouseEvent.MOUSE_DRAGGED:
return ((me.getModifiersEx() & InputEvent.BUTTON1_DOWN_MASK) != 0);
}
return false;
}
示例10: eventToString
private static String eventToString(MouseEvent e) {
StringBuilder result = new StringBuilder();
switch (e.getID()) {
case MouseEvent.MOUSE_PRESSED:
result.append("MOUSE_PRESSED");
break;
case MouseEvent.MOUSE_RELEASED:
result.append("MOUSE_RELEASED");
break;
case MouseEvent.MOUSE_CLICKED:
result.append("MOUSE_CLICKED");
break;
case MouseEvent.MOUSE_ENTERED:
result.append("MOUSE_ENTERED");
break;
case MouseEvent.MOUSE_EXITED:
result.append("MOUSE_EXITED");
break;
case MouseEvent.MOUSE_MOVED:
result.append("MOUSE_MOVED");
break;
case MouseEvent.MOUSE_DRAGGED:
result.append("MOUSE_DRAGGED");
break;
case MouseEvent.MOUSE_WHEEL:
result.append("MOUSE_WHEEL");
break;
default:
result.append("unknown type");
}
result.append(", modifiers = " + MouseEvent.getMouseModifiersText(e.getModifiers()));
result.append(", modifiersEx = " + MouseEvent.getMouseModifiersText(e.getModifiersEx()));
result.append(", button = " + e.getButton());
return result.toString();
}
示例11: processMouseEvents
/**
* Processes all caught <code>MouseEvent</code>s.
*
* @param e the <code>MouseEvent</code>
*/
private void processMouseEvents(MouseEvent e) {
int tabNumber = getUI().tabForCoordinate(this, e.getX(), e.getY());
if (tabNumber < 0)
return;
CloseTabIcon icon = (CloseTabIcon) getIconAt(tabNumber);
if (icon != null) {
Rectangle rect = icon.getBounds();
Point pos = headerViewport == null ? new Point() : headerViewport
.getViewPosition();
Rectangle drawRect = new Rectangle(rect.x - pos.x, rect.y - pos.y,
rect.width, rect.height);
if (e.getID() == MouseEvent.MOUSE_PRESSED) {
icon.mousepressed = e.getModifiers() == MouseEvent.BUTTON1_MASK;
repaint(drawRect);
} else if (e.getID() == MouseEvent.MOUSE_MOVED
|| e.getID() == MouseEvent.MOUSE_DRAGGED
|| e.getID() == MouseEvent.MOUSE_CLICKED) {
pos.x += e.getX();
pos.y += e.getY();
if (rect.contains(pos)) {
if (e.getID() == MouseEvent.MOUSE_CLICKED) {
int selIndex = getSelectedIndex();
if (fireCloseTab(selIndex)) {
if (selIndex > 0) {
// to prevent uncatchable null-pointers
Rectangle rec = getUI().getTabBounds(this,
selIndex - 1);
MouseEvent event = new MouseEvent((Component) e
.getSource(), e.getID() + 1, System
.currentTimeMillis(), e.getModifiers(),
rec.x, rec.y, e.getClickCount(), e
.isPopupTrigger(), e
.getButton());
dispatchEvent(event);
}
// the tab is being closed
// removeTabAt(tabNumber);
remove(selIndex);
} else {
icon.mouseover = false;
icon.mousepressed = false;
repaint(drawRect);
}
} else {
icon.mouseover = true;
icon.mousepressed = e.getModifiers() == MouseEvent.BUTTON1_MASK;
}
} else {
icon.mouseover = false;
}
repaint(drawRect);
}
}
}
示例12: processMouseEvents
/**
* Processes all caught <code>MouseEvent</code>s.
*
* @param e the <code>MouseEvent</code>
*/
private void processMouseEvents(MouseEvent e) {
int tabNumber = getUI().tabForCoordinate(this, e.getX(), e.getY());
if (tabNumber < 0) {
return;
}
CloseTabIcon icon = (CloseTabIcon) getIconAt(tabNumber);
if (icon != null) {
// TODO: draw states of button '+'
if (icon instanceof AddTabIcon && (e.getID() == MouseEvent.MOUSE_CLICKED)) {
tabButtonPressed();
return;
}
/* allow all tabs closing feature */
if (getTabCount() <= (allowAllTabsClosing ? (addTabLabel != null ? 1 : 0)
: addTabLabel != null ? 2 : 1)) {
return;
}
Rectangle rect = icon.getBounds();
Point pos = headerViewport == null ? new Point() : headerViewport
.getViewPosition();
Rectangle drawRect = new Rectangle(rect.x - pos.x, rect.y - pos.y,
rect.width, rect.height);
if (e.getID() == MouseEvent.MOUSE_PRESSED) {
icon.mousepressed = e.getModifiers() == MouseEvent.BUTTON1_MASK;
repaint(drawRect);
} else if (e.getID() == MouseEvent.MOUSE_MOVED
|| e.getID() == MouseEvent.MOUSE_DRAGGED
|| e.getID() == MouseEvent.MOUSE_CLICKED) {
pos.x += e.getX();
pos.y += e.getY();
if (rect.contains(pos)) {
if (e.getID() == MouseEvent.MOUSE_CLICKED) {
int selIndex = getSelectedIndex();
if (fireCloseTab(selIndex)) {
if (selIndex > 0) {
// to prevent uncatchable null-pointers
Rectangle rec = getUI().getTabBounds(this,
selIndex - 1);
MouseEvent event = new MouseEvent((Component) e
.getSource(), e.getID() + 1, System
.currentTimeMillis(), e.getModifiers(),
rec.x, rec.y, e.getClickCount(), e
.isPopupTrigger(), e
.getButton());
dispatchEvent(event);
}
// the tab is being closed
// removeTabAt(tabNumber);
//remove(selIndex);
removeTabAt(selIndex);
} else {
icon.mouseover = false;
icon.mousepressed = false;
repaint(drawRect);
}
} else {
icon.mouseover = true;
icon.mousepressed = e.getModifiers() == MouseEvent.BUTTON1_MASK;
}
} else {
icon.mouseover = false;
}
repaint(drawRect);
}
}
}