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


Java MouseInputListener类代码示例

本文整理汇总了Java中javax.swing.event.MouseInputListener的典型用法代码示例。如果您正苦于以下问题:Java MouseInputListener类的具体用法?Java MouseInputListener怎么用?Java MouseInputListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: handleEntranceAndExit

import javax.swing.event.MouseInputListener; //导入依赖的package包/类
private void handleEntranceAndExit( MouseEvent e ) {
    MouseInputListener unit = getHandler( e );
    if ( unit == null ) {
        if ( activeUnit != null ) {
            activeUnit.mouseExited( e );
            activeUnit = null;
        }
    }
    else if ( unit != null ) {
        if ( activeUnit == unit ) {
            //same guy
        }
        else if ( activeUnit == null ) {
            //Fire a grabber entered, set the active unit.
            activeUnit = unit;
            activeUnit.mouseEntered( e );
        }
        else if ( activeUnit != unit ) {
            //Switch active units.
            activeUnit.mouseExited( e );
            activeUnit = unit;
            activeUnit.mouseEntered( e );
        }
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:26,代码来源:MouseManager.java

示例2: getHandler

import javax.swing.event.MouseInputListener; //导入依赖的package包/类
private MouseInputListener getHandler( MouseEvent e ) {
//    private BoundedMouseListener getHandler( MouseEvent e ) {
//        DefaultInteractiveGraphic[] units = (DefaultInteractiveGraphic[])am.toArray( new DefaultInteractiveGraphic[0] );
        Iterator it = am.reverseIterator();
        while( it.hasNext() ) {
            Object o = it.next();
            if( o instanceof Boundary && o instanceof MouseInputListener ) {
                Boundary boundary = (Boundary)o;
                if( boundary.contains( e.getX(), e.getY() ) ) {
                    return (MouseInputListener)boundary;
                }
            }
//        BoundedMouseListener[] units = (BoundedMouseListener[])am.toArray( new BoundedMouseListener[0] );
//        for( int i = units.length - 1; i >= 0; i-- ) {
//            DefaultInteractiveGraphic unit = units[i];
//            BoundedMouseListener unit = units[i];
//            if( unit.contains( e.getX(), e.getY() ) ) {
//            if( unit.getAbstractShape().contains( e.getX(), e.getY() ) ) {
//                return unit;
//            }
        }
        return null;
    }
 
开发者ID:mleoking,项目名称:PhET,代码行数:24,代码来源:MouseManager.java

示例3: setMouseAndKeyListeners

import javax.swing.event.MouseInputListener; //导入依赖的package包/类
/**
 * Sets up mouse and key listeners
 */
protected void setMouseAndKeyListeners( MouseInputListener mouseHandler, KeyListener keyAdapter ) {
    // Clear the old handlers
    MouseListener[] mouseListeners = this.getMouseListeners();
    for ( int i = 0; i < mouseListeners.length; i++ ) {
        MouseListener mouseListener = mouseListeners[i];
        this.removeMouseListener( mouseListener );
    }
    MouseMotionListener[] mouseMostionListeners = this.getMouseMotionListeners();
    for ( int i = 0; i < mouseMostionListeners.length; i++ ) {
        MouseMotionListener mouseMostionListener = mouseMostionListeners[i];
        this.removeMouseMotionListener( mouseMostionListener );
    }
    KeyListener[] keyListeners = this.getKeyListeners();
    for ( int i = 0; i < keyListeners.length; i++ ) {
        KeyListener keyListener = keyListeners[i];
        this.removeKeyListener( keyListener );
    }

    // Add the new handlers
    this.addMouseListener( mouseHandler );
    this.addMouseMotionListener( getGraphic().getMouseHandler() );
    this.addKeyListener( keyAdapter );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:27,代码来源:ApparatusPanel.java

示例4: installWindowListeners

import javax.swing.event.MouseInputListener; //导入依赖的package包/类
/**
 * <p>创建窗体鼠标监听器, 处理窗体的移动和拖拽事件</p>
 * 
 * <p>Create Window mouse listener, handle window move and drag event.</p>
 *
 * @param root <code>JRootPane</code>
 * @return <code>MouseInputListener</code> window move and drag event listener.
 */
protected MouseInputListener installWindowListeners(JRootPane root)
{
    Window window = SwingUtilities.getWindowAncestor(root);

    if (window != null)
    {
        if (mouseInputListener == null)
        {
            mouseInputListener = new WindowMouseHandler(root);
        }

        window.addMouseListener(mouseInputListener);

        window.addMouseMotionListener(mouseInputListener);
    }

    return mouseInputListener;
}
 
开发者ID:freeseawind,项目名称:littleluck,代码行数:27,代码来源:LuckRootPaneUI.java

示例5: GISDataView

import javax.swing.event.MouseInputListener; //导入依赖的package包/类
/** */
public GISDataView () {
    setOpaque(true);
    setPreferredSize(new Dimension(300, 300));
    setBackground(Color.WHITE);
    _shapes = new ArrayList<Shape>();
    _transform = new ProjectedSpaceToPixelSpaceTransform(new Point2D.Float(0.0f, 0.0f),
                                                         180.0 / 300.0,
                                                         new Point2D.Float(150f, 150f));
    _proj = null;
    MouseInputListener dragListener = new DragListener();
    addMouseListener(dragListener);
    addMouseMotionListener(dragListener);
    addMouseWheelListener(new ZoomListener());
    setSize(getPreferredSize());
}
 
开发者ID:reuven,项目名称:modelingcommons,代码行数:17,代码来源:GISDataView.java

示例6: updateUI

import javax.swing.event.MouseInputListener; //导入依赖的package包/类
@Override
public void updateUI() {

    // register(or not) listener for selection
    if  (allowSelection) {
        setUI(new BasicGridHeaderUI());
    } else  {
        setUI(new BasicGridHeaderUI() {
            @Override
            protected MouseInputListener createMouseInputListener() {
                return null;
            }
        });
    }

    // register listener for cell resize
    if (resize) {
        setUI(new BasicGridHeaderUI() {
            protected MouseInputListener createMouseInputListener() {
                return new HeaderResizeMouseInputListener();
            }
        });
    }
    
    repaintManager.resizeAndRepaint();
}
 
开发者ID:nextreports,项目名称:nextreports-designer,代码行数:27,代码来源:JGridHeader.java

示例7: getHandler

import javax.swing.event.MouseInputListener; //导入依赖的package包/类
private MouseInputListener getHandler( MouseEvent e ) {
    Iterator it = am.reverseIterator();
    while ( it.hasNext() ) {
        Object o = it.next();
        if ( o instanceof Boundary && o instanceof MouseInputListener ) {
            Boundary boundary = (Boundary) o;
            if ( boundary.contains( e.getX(), e.getY() ) ) {
                return (MouseInputListener) boundary;
            }
        }
    }
    return null;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:14,代码来源:MouseManager.java

示例8: startDragging

import javax.swing.event.MouseInputListener; //导入依赖的package包/类
public void startDragging( MouseInputListener inputListener, MouseEvent event ) {
    if ( activeUnit != null ) {
        activeUnit.mouseReleased( event );//could be problems if expected event==RELEASE_EVENT
    }
    activeUnit = inputListener;
    activeUnit.mouseDragged( event );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:8,代码来源:MouseManager.java

示例9: handleEntranceAndExit

import javax.swing.event.MouseInputListener; //导入依赖的package包/类
private void handleEntranceAndExit( MouseEvent e ) {
        MouseInputListener unit = getHandler( e );
//        BoundedMouseListener unit = getHandler( e );
        if( unit == null ) {
            if( activeUnit != null ) {
                activeUnit.mouseExited( e );
//                activeUnit.getMouseInputListener().mouseExited( e );
                activeUnit = null;
            }
        }
        else if( unit != null ) {
            if( activeUnit == unit ) {
                //same guy
            }
            else if( activeUnit == null ) {
                //Fire a mouse entered, set the active unit.
                activeUnit = unit;
                activeUnit.mouseEntered( e );
//                activeUnit.getMouseInputListener().mouseEntered( e );
            }
            else if( activeUnit != unit ) {
                //Switch active units.
                activeUnit.mouseExited( e );
//                activeUnit.getMouseInputListener().mouseExited( e );
                activeUnit = unit;
                activeUnit.mouseEntered( e );
//                activeUnit.getMouseInputListener().mouseEntered( e );
            }
        }
    }
 
开发者ID:mleoking,项目名称:PhET,代码行数:31,代码来源:MouseManager.java

示例10: startDragging

import javax.swing.event.MouseInputListener; //导入依赖的package包/类
public void startDragging( MouseEvent event, MouseInputListener activeUnit ) {
    if( this.activeUnit != null ) {
        this.activeUnit.mouseExited( event );
    }
    this.activeUnit = activeUnit;
    activeUnit.mouseEntered( event );
    activeUnit.mousePressed( event );
    activeUnit.mouseDragged( event );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:10,代码来源:CompositeInteractiveGraphicMouseDelegator.java

示例11: handleEntranceAndExit

import javax.swing.event.MouseInputListener; //导入依赖的package包/类
public void handleEntranceAndExit( MouseEvent e ) {
        // Find the topmost graphic that can handle the event
        MouseInputListener unit = getLeaf( e.getPoint(), compositeInteractiveGraphic );
        if( unit == null ) {
            // If the mouse isn't over anything contained in the
            // CompositeGraphic...
            if( activeUnit != null ) {
                activeUnit.mouseExited( e );
                activeUnit = null;
            }
        }
        else {//unit was non-null.
            if( activeUnit == unit ) {
                //same guy
            }
            else if( activeUnit == null ) {
                //Fire a mouse entered, set the active unit.
                activeUnit = unit;
                activeUnit.mouseEntered( e );
            }
            else if( activeUnit != unit ) {
                //Switch active units.
                activeUnit.mouseExited( e );
                activeUnit = unit;
                activeUnit.mouseEntered( e );
            }
        }
//        System.out.println( "activeUnit = " + activeUnit );
    }
 
开发者ID:mleoking,项目名称:PhET,代码行数:30,代码来源:CompositeInteractiveGraphicMouseDelegator.java

示例12: ColorControl

import javax.swing.event.MouseInputListener; //导入依赖的package包/类
/**
 * Constructor.
 *
 * @param labelString
 * @param color
 * @param chipSize
 */
public ColorControl( Frame parentFrame, String labelString, Color color, Dimension chipSize ) {
    super();

    this.parentFrame = parentFrame;
    this.labelString = labelString;
    this.chipSize = new Dimension( chipSize );
    listenerList = new EventListenerList();

    MouseInputListener mouseInputListener = new MouseInputAdapter() {
        public void mouseClicked( MouseEvent event ) {
            openColorChooser();
        }
    };

    JLabel label = new JLabel( labelString );
    label.addMouseListener( mouseInputListener );

    colorChip = new JLabel();
    colorChip.addMouseListener( mouseInputListener );

    add( label );
    add( Box.createHorizontalStrut( 5 ) );
    add( colorChip );

    setColor( color );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:34,代码来源:ColorControl.java

示例13: subscribe

import javax.swing.event.MouseInputListener; //导入依赖的package包/类
/**
 * Insert the method's description here.
 * Creation date: (18.12.2000 16:25:04)
 * @param subscriberID java.lang.String
 * @param listener javax.swing.event.MouseInputListener
 */
public void subscribe(String subscriberID, MouseInputListener listener) {
	JComponent comp = (JComponent)getSubscriber().get(subscriberID);
	if (comp!=null) {
		DoubleClickProxy proxy = new DoubleClickProxy(listener);
		comp.addMouseListener(proxy);
		comp.addMouseMotionListener(proxy);
	} else {
		//System.err.println("Warning: subscriber with id " + subscriberID + " doesn't exist.");
	}
}
 
开发者ID:epics-extensions,项目名称:VisualDCT,代码行数:17,代码来源:MouseEventManager.java

示例14: unsubscribe

import javax.swing.event.MouseInputListener; //导入依赖的package包/类
/**
 * Insert the method's description here.
 * Creation date: (18.12.2000 16:25:04)
 * @param subscriberID java.lang.String
 * @param listener javax.swing.event.MouseInputListener
 */
public void unsubscribe(String subscriberID, MouseInputListener listener) {
	JComponent comp = (JComponent)getSubscriber().get(subscriberID);
	if (comp!=null) {
		comp.removeMouseListener(listener);
		comp.removeMouseMotionListener(listener);
	}
}
 
开发者ID:epics-extensions,项目名称:VisualDCT,代码行数:14,代码来源:MouseEventManager.java

示例15: installWindowListeners

import javax.swing.event.MouseInputListener; //导入依赖的package包/类
/**
 * 自定义拖拽区域
 */
protected MouseInputListener installWindowListeners(JRootPane root)
{
    MouseInputListener listener = super.installWindowListeners(root);

    if(listener instanceof WindowMouseHandler)
    {
        ((WindowMouseHandler) listener).setDragArea(new LuckRectangle(root));
    }

    return listener;
}
 
开发者ID:freeseawind,项目名称:littleluck,代码行数:15,代码来源:FrameDemo.java


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