本文整理汇总了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);
}
}
示例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);
}
示例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);
}
}
示例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;
}
}
}
});
}
示例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);
}
示例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);
}
}
示例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);
}
}
示例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;
}
}
}
示例9: add
import java.awt.Component; //导入方法依赖的package包/类
@Override
public Component add(Component c) {
Component result = super.add(c);
c.addMouseListener(borderListener);
return result;
}
示例10: addToComponent
import java.awt.Component; //导入方法依赖的package包/类
public void addToComponent(final Component c) {
c.addMouseListener(listener);
c.addMouseMotionListener(listener);
}
示例11: MouseManager
import java.awt.Component; //导入方法依赖的package包/类
public MouseManager(Component component, G3DSys gs) {
component.addMouseListener(this);
component.addMouseMotionListener(this);
c = component;
gsys = gs;
}
示例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);
}
示例13: addListeners
import java.awt.Component; //导入方法依赖的package包/类
private void addListeners(Component com) {
com.addMouseListener(ma);
com.addMouseMotionListener(mma);
}