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


Java MouseEvent.getModifiers方法代码示例

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


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

示例1: mouseDragged

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
public void mouseDragged(MouseEvent e) {
	
	if (station){
		//if a datapoint is selected, move it to a new location and update the lat/lon values.
		//only works for editable datasets (ie imported datasets)
		if (tm.editable && selectedRow >= 0) {
			Point2D latlon = getMouseLatLon(e);
			tm.setValueAt(String.valueOf(latlon.getX()), selectedRow, lonIndex);
			tm.setValueAt(String.valueOf(latlon.getY()), selectedRow, latIndex);
		}
	}
	
	if (db.panTB.isSelected() || e.getModifiers()==4 || !db.lassoTB.isSelected()) return;

	if (poly!=null){
		if (Math.abs(poly.xpoints[poly.npoints-1]-e.getX())<=1
				&&Math.abs(poly.ypoints[poly.npoints-1]-e.getY())<=1)  return;
		poly.addPoint(e.getX(), e.getY());
		drawLasso();
	} else if (p1!=null) {
		drawSelectionBox();
		p2=e.getPoint();
		drawSelectionBox();
	}
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:26,代码来源:UnknownDataSet.java

示例2: adjustCaret

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
/**
 * Adjusts the caret location based on the MouseEvent.
 */
private void adjustCaret(MouseEvent e) {
	if ((e.getModifiers()&ActionEvent.SHIFT_MASK)!=0 && getDot()!=-1) {
		moveCaret(e);
	}
	else {
		positionCaret(e);
	}
}
 
开发者ID:Thecarisma,项目名称:powertext,代码行数:12,代码来源:ConfigurableCaret.java

示例3: convertMouseEvent

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
private MouseEvent convertMouseEvent( MouseEvent e ) {
    Point convertedPoint = SwingUtilities.convertPoint( (Component)e.getSource(),
            e.getPoint(), list );
    MouseEvent newEvent = new MouseEvent( (Component)e.getSource(),
            e.getID(),
            e.getWhen(),
            e.getModifiers(),
            convertedPoint.x,
            convertedPoint.y,
            e.getClickCount(),
            e.isPopupTrigger() );
    return newEvent;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:FileCompletionPopup.java

示例4: test

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
private static void test(final Frame frame, final MouseEvent me) {
    MouseEvent newme = SwingUtilities.convertMouseEvent(frame, me, frame);
    if (me.getModifiersEx() != newme.getModifiersEx()
            || me.getModifiers() != newme.getModifiers()) {
        fail(me, newme);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:bug7170657.java

示例5: handleRelease

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
@Override
public void handleRelease(MouseEvent e) {
	mediator.setIsReleased(true);
	try {
		if (e != null && !e.isConsumed()) {
			if (ml.getHandler() == ml.getMarquee() && ml.getMarquee() != null) {
				ml.getMarquee().mouseReleased(e);
			} else if (ml.getHandler() == ml.getHandle() && ml.getHandle() != null) {
				ml.getHandle().mouseReleased(e);
			}
			if (ml.isDescendant(ml.getCell(), ml.getFocus()) && e.getModifiers() != 0) {
				// Do not switch to parent if Special Selection
				ml.setCell(ml.getFocus());
			}

			// Puts selected cells in good place to avoid overlapping
			if (moved && Xmin.length > 0 && Ymin.length > 0) {
				mediator.putSelectedCellsInGoodPlace(cells, Xmin, Ymin);
				mediator.avoidOverlappingCell(cells);
				moved = false;
			}

			if (!e.isConsumed() && ml.getCell() != null) {
				Object tmp = ml.getCell().getCell();
				boolean wasSelected = mediator.isCellSelected(tmp);
				mediator.selectCellForEvent(tmp, e);
				ml.setFocus(ml.getCell());
				ml.postProcessSelection(e, tmp, wasSelected);
			}
			// Notify mediator that object can have been placed inside or
			// outside a blocking region
			mediator.handlesBlockingRegionDrag();
		}
	} finally {
		ml.setHandler(null);
		ml.setCell(null);
	}

}
 
开发者ID:max6cn,项目名称:jmt,代码行数:40,代码来源:SelectState.java

示例6: mouseClicked

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
public void mouseClicked(MouseEvent e) {
	// GMA 1.6.4: Center on spot where user double-clicks (but not if Digitizer is open)
	if ( e.getClickCount() >= 2 && e.getModifiers()==16 && !((MapApp)app).digitizer.isEnabled()) {
		Point p = e.getPoint();
		doZoom( p, 1 );
	}
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:8,代码来源:XMap.java

示例7: mouseClicked

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
public void mouseClicked(MouseEvent e) {
    if ((e.getModifiers() == InputEvent.BUTTON1_MASK) && (e.getClickCount() == 2)) {
        if (isMaximized()) {
            restore();
        } else {
            maximize();
        }
    }

    ;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:JTitledPanel.java

示例8: mousePressed

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
@Override
public void mousePressed(MouseEvent e) {

    modMouse = e.getModifiers();
    modMouseEx = e.getModifiersEx();
    mousePressFired = true;
    synchronized (lock) { lock.notifyAll(); }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:MouseButtonsAndKeyMasksTest.java

示例9: createEvent

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
private MouseEvent createEvent(final MouseEvent original) {
  return new MouseEvent(original.getComponent(), original.getID(), original.getWhen(), original.getModifiers(), (int) this.getLocation().getX(), (int) this.getLocation().getY(), original.getXOnScreen(), original.getYOnScreen(), original.getClickCount(), original.isPopupTrigger(),
      original.getButton());
}
 
开发者ID:gurkenlabs,项目名称:litiengine,代码行数:5,代码来源:Mouse.java

示例10: oldIsRightMouseButton

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
private static boolean oldIsRightMouseButton(MouseEvent e) {
    return ((e.getModifiers() & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:4,代码来源:bug7146377.java

示例11: mouseMoved

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
@Override
    public void mouseMoved(MouseEvent e) {
        JTextPane pane = (JTextPane)e.getSource();
        StyledDocument doc = pane.getStyledDocument();

        int offset = pane.viewToModel(e.getPoint());
        Element elem = doc.getCharacterElement(offset);

        Highlight h = getHighlight(pane, offset);
        Highlight prevHighlight = (Highlight) pane.getClientProperty(PREV_HIGHLIGHT_PROPERTY);
        AttributeSet prevAs = (AttributeSet) pane.getClientProperty(PREV_HIGHLIGHT_ATTRIBUTES);
//        if(h != null && h.equals(prevHighlight)) {
//            return; // nothing to do
//        } else 
        if(prevHighlight != null && prevAs != null) {
            doc.setCharacterAttributes(prevHighlight.startOffset, prevHighlight.endOffset - prevHighlight.startOffset, prevAs, true);
            pane.putClientProperty(PREV_HIGHLIGHT_PROPERTY, null);
            pane.putClientProperty(PREV_HIGHLIGHT_ATTRIBUTES, null);
        }

        int modifiers = e.getModifiers() | e.getModifiersEx();
        if ( (modifiers & InputEvent.CTRL_DOWN_MASK) == InputEvent.CTRL_DOWN_MASK ||
             (modifiers & InputEvent.META_DOWN_MASK) == InputEvent.META_DOWN_MASK) 
        {            
            AttributeSet as = elem.getAttributes();
            if (StyleConstants.isUnderline(as)) {
                // do not underline whats already underlined
                return;
            }

            Font font = doc.getFont(as);
            FontMetrics fontMetrics = pane.getFontMetrics(font);
            try {
                Rectangle rectangle = new Rectangle(
                        pane.modelToView(elem.getStartOffset()).x,
                        pane.modelToView(elem.getStartOffset()).y,
                        fontMetrics.stringWidth(doc.getText(elem.getStartOffset(), elem.getEndOffset() - elem.getStartOffset())),
                        fontMetrics.getHeight());

                if (h != null && offset < elem.getEndOffset() - 1 && rectangle.contains(e.getPoint())) {
                    Style hlStyle = doc.getStyle("regularBlue-findtype");               // NOI18N

                    pane.putClientProperty(PREV_HIGHLIGHT_ATTRIBUTES, as.copyAttributes());
                    doc.setCharacterAttributes(h.startOffset, h.endOffset - h.startOffset, hlStyle, true);
    //                doc.setCharacterAttributes(h.startOffset, h.endOffset - h.startOffset, as.copyAttributes(), true);
                    pane.putClientProperty(PREV_HIGHLIGHT_PROPERTY, h);
                } 
            } catch (BadLocationException ex) {
                Exceptions.printStackTrace(ex);
            }
        }
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:53,代码来源:FindTypesSupport.java

示例12: isCellEditable

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
/**
 * Overridden to return false, and if the event is a mouse event it is
 * forwarded to the tree.
 * <p>
 * The behavior for this is debatable, and should really be offered as a
 * property. By returning false, all keyboard actions are implemented in
 * terms of the table. By returning true, the tree would get a chance to
 * do something with the keyboard events. For the most part this is ok.
 * But for certain keys, such as left/right, the tree will
 * expand/collapse where as the table focus should really move to a
 * different column. Page up/down should also be implemented in terms of
 * the table. By returning false this also has the added benefit that
 * clicking outside of the bounds of the tree node, but still in the
 * tree column will select the row, whereas if this returned true that
 * wouldn't be the case.
 * <p>
 * By returning false we are also enforcing the policy that the tree
 * will never be editable (at least by a key sequence).
 */
public boolean isCellEditable(EventObject e) {
	if (e instanceof MouseEvent) {
		for (int counter = getColumnCount() - 1; counter >= 0; counter--) {
			if (getColumnClass(counter) == TreeTableModel.class) {
				MouseEvent me = (MouseEvent) e;
				MouseEvent newME = new MouseEvent(tree, me.getID(), me
						.getWhen(), me.getModifiers(), me.getX()
						- getCellRect(0, counter, true).x, me.getY(),
						me.getClickCount(), me.isPopupTrigger());
				tree.dispatchEvent(newME);
				break;
			}
		}
	}
	return false;
}
 
开发者ID:ser316asu,项目名称:SER316-Aachen,代码行数:36,代码来源:JTreeTable.java

示例13: isCellEditable

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
/**
 * Overridden to return false, and if the event is a mouse event it is
 * forwarded to the tree.
 * <p>
 * The behavior for this is debatable, and should really be offered as a
 * property. By returning false, all keyboard actions are implemented in
 * terms of the table. By returning true, the tree would get a chance to
 * do something with the keyboard events. For the most part this is ok.
 * But for certain keys, such as left/right, the tree will
 * expand/collapse where as the table focus should really move to a
 * different column. Page up/down should also be implemented in terms of
 * the table. By returning false this also has the added benefit that
 * clicking outside of the bounds of the tree node, but still in the
 * tree column will select the row, whereas if this returned true that
 * wouldn't be the case.
 * <p>
 * By returning false we are also enforcing the policy that the tree
 * will never be editable (at least by a key sequence).
 */
public boolean isCellEditable(EventObject e) {
    if (e instanceof MouseEvent) {
        for (int counter = getColumnCount() - 1; counter >= 0; counter--) {
            if (getColumnClass(counter) == TreeTableModel.class) {
                MouseEvent me = (MouseEvent) e;
                MouseEvent newME = new MouseEvent(tree, me.getID(), me
                        .getWhen(), me.getModifiers(), me.getX()
                        - getCellRect(0, counter, true).x, me.getY(),
                        me.getClickCount(), me.isPopupTrigger());
                tree.dispatchEvent(newME);
                break;
            }
        }
    }
    return false;
}
 
开发者ID:ser316asu,项目名称:SER316-Dresden,代码行数:36,代码来源:TaskTable.java

示例14: oldIsMiddleMouseButton

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
private static boolean oldIsMiddleMouseButton(MouseEvent e) {
    return ((e.getModifiers() & InputEvent.BUTTON2_MASK) == InputEvent.BUTTON2_MASK);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:4,代码来源:bug7146377.java

示例15: handleJavaMouseEvent

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
void handleJavaMouseEvent(MouseEvent e) {
    super.handleJavaMouseEvent(e);
    int id = e.getID();
    switch (id) {
      case MouseEvent.MOUSE_PRESSED:
          if (XToolkit.isLeftMouseButton(e) ) {
              Button b = (Button) e.getSource();

              if(b.contains(e.getX(), e.getY())) {
                  if (!isEnabled()) {
                      // Disabled buttons ignore all input...
                      return;
                  }
                  pressed = true;
                  armed = true;
                  repaint();
              }
          }

          break;

      case MouseEvent.MOUSE_RELEASED:
          if (XToolkit.isLeftMouseButton(e)) {
              if (armed)
              {
                  @SuppressWarnings("deprecation")
                  final int modifiers = e.getModifiers();
                  action(e.getWhen(), modifiers);
              }
              pressed = false;
              armed = false;
              repaint();
          }

          break;

      case  MouseEvent.MOUSE_ENTERED:
          if (pressed)
              armed = true;
          break;
      case MouseEvent.MOUSE_EXITED:
          armed = false;
          break;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:46,代码来源:XButtonPeer.java


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