本文整理匯總了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 );
}
}
}
示例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;
}
示例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 );
}
示例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;
}
示例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());
}
示例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();
}
示例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;
}
示例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 );
}
示例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 );
}
}
}
示例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 );
}
示例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 );
}
示例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 );
}
示例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.");
}
}
示例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);
}
}
示例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;
}