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


Java MouseEvent.getID方法代码示例

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


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

示例1: processMouseEvent

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
@Override protected void processMouseEvent(MouseEvent event) {
	super.processMouseEvent(event);
	switch(event.getID()) {
	case MouseEvent.MOUSE_CLICKED:
		if(event.getButton()!=MouseEvent.BUTTON1)
			return;
		Point point = applyZoom(event.getPoint());
		Component component = searchComponentAt(point);
		if(component==null) return;
		else if(component instanceof Interactable) {
			event = new RelativeMouseEvent(event, point, component.getLocation());
			if(Utilities.isOdd(event.getClickCount()))
				((Interactable) component).mouseClick(event);
			else ((Interactable) component).mouseDoubleClick(event);
		}
		if(!isSimulating()&&event.getButton()==MouseEvent.BUTTON1&&
				event.getClickCount()>=2)
			showComponentConfigurationDialog(component);
	}
}
 
开发者ID:kristian,项目名称:JDigitalSimulator,代码行数:21,代码来源:Simulation.java

示例2: eventDispatched

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
public void eventDispatched(java.awt.AWTEvent aWTEvent) {
    if (aWTEvent instanceof MouseEvent) {
        MouseEvent mv = (MouseEvent)aWTEvent;
        if (mv.getID() == MouseEvent.MOUSE_CLICKED && mv.getClickCount() > 0) {
            //#118828
            if (! (aWTEvent.getSource() instanceof Component)) {
                removePopup();
                return;
            }
            
            Component comp = (Component)aWTEvent.getSource();
            Container par1 = SwingUtilities.getAncestorNamed(POPUP_NAME, comp); //NOI18N
            Container par2 = SwingUtilities.getAncestorNamed(SUB_POPUP_NAME, comp); //NOI18N
            // Container barpar = SwingUtilities.getAncestorOfClass(PopupUtil.class, comp);
            // if (par == null && barpar == null) {
            if ( par1 == null && par2 == null ) {
                removePopup();
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:HintsUI.java

示例3: convertEvent

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
protected MouseEvent convertEvent(MouseEvent e){
  int column = 0;
  int row = rowAtPoint(e.getPoint());

  //move the event from table to tree coordinates
  Rectangle tableCellRect = getCellRect(row, column, false);
  Rectangle treeCellRect = tree.getRowBounds(row);
  int dx = 0;
  if(tableCellRect != null) dx = -tableCellRect.x;
  int dy = 0;
  if(tableCellRect !=null && treeCellRect != null)
    dy = treeCellRect.y -tableCellRect.y;
  e.translatePoint(dx, dy);


  return new MouseEvent(
    tree, e.getID(), e.getWhen(), e.getModifiers(),
    e.getX(), e.getY(), e.getClickCount(), e.isPopupTrigger()
  );
}
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:21,代码来源:JTreeTable.java

示例4: processMouseEvent

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
/**
 * Processes a mouse event.
 *
 * @param e the MouseEvent
 */
@Override protected void processMouseEvent(MouseEvent e) {
    super.processMouseEvent(e);
    if (!e.isConsumed()) {
        if (e.isPopupTrigger()) {
            // Show a popup allowing to configure the various options
            showPopup(e.getX(), e.getY());
        }  else if (e.getID() == e.MOUSE_ENTERED) {
            containsMouse = true;
            cachedBorderVaild = false;
            repaint();
        } else if (e.getID() == e.MOUSE_EXITED) {
            containsMouse = false;
            cachedBorderVaild = false;
            repaint();
        }

    } 
    
    if (e.getID() == MouseEvent.MOUSE_CLICKED &&
            SwingUtilities.isLeftMouseButton(e) && 
            e.getClickCount() == 1) {
        // Trigger a gc
        GarbageCollectAction.get(GarbageCollectAction.class).performAction();;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:31,代码来源:HeapView.java

示例5: processEvent

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
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);
    }
}
 
开发者ID:lead4good,项目名称:open-java-trade-manager,代码行数:12,代码来源:ChartLayerUI.java

示例6: eventDispatched

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
@Override
public void eventDispatched(AWTEvent event) {
    if (event instanceof MouseEvent) {
        MouseEvent e = (MouseEvent) event;
        if (e.getID() == MouseEvent.MOUSE_ENTERED) {
            mouseComponent = e.getComponent();
        } else if (e.getID() == MouseEvent.MOUSE_EXITED) {
            mouseComponent = null;
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:12,代码来源:EventDispatcher.java

示例7: processMouseEvent

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
@Override
protected void processMouseEvent(MouseEvent me) {
    if (isEnabled() && me.getID() == MouseEvent.MOUSE_PRESSED) {
        startTimer();
    } else if (me.getID() == MouseEvent.MOUSE_RELEASED) {
        stopTimer();
    }
    super.processMouseEvent(me);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:ButtonFactory.java

示例8: 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

示例9: eventDispatched

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
public void eventDispatched(AWTEvent event) {
    if (event instanceof MouseEvent) {
        MouseEvent me = (MouseEvent) event;
        Component mecmp = me.getComponent();

        if (!SwingUtilities.isDescendingFrom(mecmp, (Component) rootPaneContainer)) {
            return;
        }
        if ((me.getID() == MouseEvent.MOUSE_EXITED) && (mecmp == rootPaneContainer)) {
            highcmp = null;
            point = null;
        } else {
            MouseEvent converted = SwingUtilities.convertMouseEvent(mecmp, me, this);
            point = converted.getPoint();
            Component parent = mecmp;
            Rectangle rect = new Rectangle();
            rect.width = mecmp.getWidth();
            rect.height = mecmp.getHeight();
            Rectangle parentBounds = new Rectangle();
            while ((parent != null) && (parent != this.getRootPane()) && (parent != rootPaneContainer)) {
                parent.getBounds(parentBounds);
                rect.x += parentBounds.x;
                rect.y += parentBounds.y;
                parent = parent.getParent();
            }
            highcmp = rect;
        }
        repaint();
    }
}
 
开发者ID:igr,项目名称:swingspy,代码行数:31,代码来源:SwingSpyGlassPane.java

示例10: handleJavaMouseEvent

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
public void handleJavaMouseEvent(MouseEvent e) {
    switch (e.getID()) {
      case MouseEvent.MOUSE_PRESSED:
          // Note that Swing requests focus in its own mouse event handler.
          if (target == e.getSource() &&
              !((Component)target).isFocusOwner() &&
              WKeyboardFocusManagerPeer.shouldFocusOnClick((Component)target))
          {
              WKeyboardFocusManagerPeer.requestFocusFor((Component)target,
                                                        FocusEvent.Cause.MOUSE_EVENT);
          }
          break;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:WComponentPeer.java

示例11: processMouseEvent

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
@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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:32,代码来源:Outline.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,代码来源:TaskTable.java

示例13: processMouseEvent

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
public void processMouseEvent (MouseEvent event) {
    switch (event.getID ()) {
      case event.MOUSE_RELEASED: // Not constant by JLS 15.27
          break;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:7,代码来源:QualifiedConstant.java

示例14: 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

示例15: processMouseEvents

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
/**
 * 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);
        }
    }
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:62,代码来源:CloseableTabbedPane.java


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