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


Java Component.addMouseListener方法代码示例

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


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

示例1: enableHints

import java.awt.Component; //导入方法依赖的package包/类
public void enableHints(Component comp, boolean enabled) {
	if (enabled)
		comp.addMouseListener(this);
	else
		comp.removeMouseListener(this);
	if (comp instanceof Container) {
		Component[] components = ((Container) comp).getComponents();
		for (int i = 0; i < components.length; i++)
			enableHints(components[i], enabled);
	}
	if (comp instanceof MenuElement) {
		MenuElement[] elements = ((MenuElement) comp).getSubElements();
		for (int i = 0; i < elements.length; i++)
			enableHints(elements[i].getComponent(), enabled);
	}
}
 
开发者ID:KeepTheBeats,项目名称:alevin-svn2,代码行数:17,代码来源:MouseOverHintManager.java

示例2: EventBinding

import java.awt.Component; //导入方法依赖的package包/类
/**
 * Creates a new Binding.
 * @param c the JOGLUI canvas
 * @param d the FengGUI Display
 */
public EventBinding(Component c, Display d) 
{
    display = d;
    
    // makes FengGUI listen to tab keys
    // http://answers.google.com/answers/threadview?id=126916
    c.setFocusTraversalKeysEnabled(false);
    
    c.addMouseListener(this);
    c.addMouseMotionListener(this);
    c.addMouseWheelListener(this);
    c.addKeyListener(this);
}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:19,代码来源:EventBinding.java

示例3: subscribeActual

import java.awt.Component; //导入方法依赖的package包/类
@Override
protected void subscribeActual(Observer<? super MouseEvent> observer) {
    Component w = widget;
    int f = flags;

    MouseEventConsumer aec = new MouseEventConsumer(observer, w, f);
    observer.onSubscribe(aec);
    if ((f & 1) != 0) {
        w.addMouseListener(aec);
    }
    if ((f & 2) != 0) {
        w.addMouseMotionListener(aec);
    }
    if ((f & 4) != 0) {
        w.addMouseWheelListener(aec);
    }
    if (aec.get() == null) {
        aec.onDispose(w);
    }
}
 
开发者ID:akarnokd,项目名称:RxJava2Swing,代码行数:21,代码来源:MouseEventObservable.java

示例4: addDropTarget

import java.awt.Component; //导入方法依赖的package包/类
public void addDropTarget(final Component c, final MouseListener l) {
  c.addMouseListener(new MouseAdapter() {
    public void mouseEntered(MouseEvent e) {
      Component source = (Component) e.getSource();
      if (source.isShowing()) {
        if (lastRelease != null) {
          e.translatePoint(source.getLocationOnScreen().x,
                           source.getLocationOnScreen().y);
          if (isCloseEnough(e.getPoint(), lastRelease.getPoint())) {
            e.translatePoint(-source.getLocationOnScreen().x,
                             -source.getLocationOnScreen().y);
            l.mouseReleased(e);
          }
        }
        else {
          dropTarget = source;
          dropHandler = l;
        }
      }
    }
  });
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:23,代码来源:DragBuffer.java

示例5: registerForMouseEvent

import java.awt.Component; //导入方法依赖的package包/类
public static void registerForMouseEvent(Component comp,
                                         MouseListener mouseListener) {
    if(comp instanceof JScrollPane) {
        JScrollPane pane = (JScrollPane) comp;
        comp = pane.getViewport().getView();
    }
    if(comp instanceof Container) {
        Container container = (Container) comp;
        Component[] components = container.getComponents();
        for(int i = 0; i < components.length; i++) {
            registerForMouseEvent(components[i], mouseListener);
        }
    }

    //No registration for XOpenTypedata that are themselves clickable.
    //No registration for JButton that are themselves clickable.
    if(comp != null &&
       (!(comp instanceof XOpenTypeViewer.XOpenTypeData) &&
        !(comp instanceof JButton)) )
        comp.addMouseListener(mouseListener);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:22,代码来源:XDataViewer.java

示例6: handleMouseOver

import java.awt.Component; //导入方法依赖的package包/类
private void handleMouseOver( Container c, MouseListener ml ) {
    c.addMouseListener(ml);
    for( Component child : c.getComponents() ) {
        child.addMouseListener(ml);
        if( child instanceof Container )
            handleMouseOver((Container)child, ml);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:BalloonManager.java

示例7: addHelp

import java.awt.Component; //导入方法依赖的package包/类
/**
 * Adds help for the specified component
 * @param comp component to be added
 * @param help help message
 */
public void addHelp(Component comp, String help) {
	if (help == null) {
		return;
	}
	Object v = map.put(comp, help);
	if (v == null) {
		comp.addMouseListener(this);
	}
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:15,代码来源:HoverHelp.java

示例8: register

import java.awt.Component; //导入方法依赖的package包/类
public void register(Component obs, GamePiece piece, int x, int y) {
  if (obs != null) {
    ComponentMouseListener l = componentMouseListeners.get(obs);
    if (l == null) {
      l = new ComponentMouseListener(piece, x, y);
      obs.addMouseListener(l);
      componentMouseListeners.put(obs, l);
    }
    else {
      l.xOffset = x;
      l.yOffset = y;
      l.target = piece;
    }
  }
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:16,代码来源:ActionButton.java

示例9: add

import java.awt.Component; //导入方法依赖的package包/类
@Override
public Component add(Component c) {
	Component result = super.add(c);
	c.addMouseListener(borderListener);
	return result;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:7,代码来源:ParentButtonPanel.java

示例10: addToComponent

import java.awt.Component; //导入方法依赖的package包/类
public void addToComponent(final Component c) {
	c.addMouseListener(listener);
	c.addMouseMotionListener(listener);
}
 
开发者ID:Njol,项目名称:Motunautr,代码行数:5,代码来源:FixedMouseAdapter.java

示例11: MouseManager

import java.awt.Component; //导入方法依赖的package包/类
public MouseManager(Component component, G3DSys gs) {
  component.addMouseListener(this);
  component.addMouseMotionListener(this);
  c = component;
  gsys = gs;
}
 
开发者ID:etomica,项目名称:etomica,代码行数:7,代码来源:MouseManager.java

示例12: showRes

import java.awt.Component; //导入方法依赖的package包/类
private static void showRes(String desc, final BufferedImage src) {
    final int w = src.getWidth();
    final int h = src.getHeight();

    Frame f = new Frame(desc+": dbl-click to exit");
    Component c;
    f.add(c = new Component() {
        public Dimension getPreferredSize() {
            return new Dimension(w,h);
        }

        public void paint(Graphics g) {
            g.clearRect(0, 0, getWidth(), getHeight());
            g.drawImage(src, 0,0, null);
        }
    });
    c.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() > 1) {
                System.exit(0);
            }
        }
    });
    f.pack();
    synchronized (JPEGsNotAcceleratedTest.class) {
        f.setLocation(frameX, frameY);
        frameX += f.getWidth();
        if ((frameX + f.getWidth()) >
            f.getGraphicsConfiguration().getBounds().width)
        {
            frameY += TEST_H;
            if ((frameY + f.getHeight()) >
                f.getGraphicsConfiguration().getBounds().height)
            {
                startY += 30;
                startX += 30;
                frameY = startY;
            }
            frameX = startX;
        }
    };
    f.setVisible(true);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:44,代码来源:JPEGsNotAcceleratedTest.java

示例13: addListeners

import java.awt.Component; //导入方法依赖的package包/类
private void addListeners(Component com) {

        com.addMouseListener(ma);
        com.addMouseMotionListener(mma);

    }
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:7,代码来源:WindowMover.java


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