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


Java JComponent.addMouseMotionListener方法代码示例

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


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

示例1: registerComponent

import javax.swing.JComponent; //导入方法依赖的package包/类
/**
    * Registers a component for tooltip management.
    * <p>
    * This will register key bindings to show and hide the tooltip text
    * only if <code>component</code> has focus bindings. This is done
    * so that components that are not normally focus traversable, such
    * as <code>JLabel</code>, are not made focus traversable as a result
    * of invoking this method.
    *
    * @param component  a <code>JComponent</code> object to add
    * @see JComponent#isFocusTraversable
    */
   protected void registerComponent(JComponent component) {
       component.removeMouseListener(this);
       component.addMouseListener(this);
       component.removeMouseMotionListener(moveBeforeEnterListener);
component.addMouseMotionListener(moveBeforeEnterListener);

if (shouldRegisterBindings(component)) {
    // register our accessibility keybindings for this component
    // this will apply globally across L&F
    // Post Tip: Ctrl+F1
    // Unpost Tip: Esc and Ctrl+F1
    InputMap inputMap = component.getInputMap(JComponent.WHEN_FOCUSED);
    ActionMap actionMap = component.getActionMap();

    if (inputMap != null && actionMap != null) {
               //XXX remove
    }
}
   }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:32,代码来源:ToolTipManagerEx.java

示例2: DragManager

import javax.swing.JComponent; //导入方法依赖的package包/类
/** Creates a new instance of SplashDnDSupport */
DragManager(JComponent component) {
    this.component = component;
    dSource =  new DragSource();
    dRecognizer = dSource.createDefaultDragGestureRecognizer(this.component,DnDConstants.ACTION_MOVE,this);
    dTarget = new DropTarget(this.component,DnDConstants.ACTION_MOVE,this);
    component.addMouseMotionListener(this);
    oCursor = component.getCursor();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:DragManager.java

示例3: beginInteractiveRotate

import javax.swing.JComponent; //导入方法依赖的package包/类
public void beginInteractiveRotate() {
  startPosition = getPosition();
  startMap = getMap();
  startMap.pushMouseListener(this);
  startMap.addDrawComponent(this);

  final JComponent view = startMap.getView();
  view.addMouseMotionListener(this);
  view.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));

  startMap.disableKeyListeners();

  pivot = getPosition();
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:15,代码来源:FreeRotator.java

示例4: initiateToolTip

import javax.swing.JComponent; //导入方法依赖的package包/类
private void initiateToolTip(MouseEvent event) {
       if (event.getSource() == window) {
           return;
       }
       JComponent component = (JComponent)event.getSource();
component.removeMouseMotionListener(moveBeforeEnterListener);

       exitTimer.stop();

Point location = event.getPoint();
// ensure tooltip shows only in proper place
if (location.x < 0 || 
    location.x >=component.getWidth() ||
    location.y < 0 ||
    location.y >= component.getHeight()) {
    return;
}

       if (insideComponent != null) {
           enterTimer.stop();
       }
// A component in an unactive internal frame is sent two
// mouseEntered events, make sure we don't end up adding
// ourselves an extra time.
       component.removeMouseMotionListener(this);
       component.addMouseMotionListener(this);

       boolean sameComponent = (insideComponent == component);

       insideComponent = component;
if (tipWindow != null){
           mouseEvent = event;
           if (showImmediately) {
               Rectangle rect = provider.getToolTipSourceBounds( event.getPoint() );
               if( null != rect ) {
                   String newToolTipText = startToolTipCalculation( rect, event.getPoint() );

                   if (!sameComponent || !toolTipText.equals(newToolTipText) /*|| 
                            !sameLoc*/) {
                       toolTipText = newToolTipText;
                       showTipWindow();
                   }
               }
           } else {
               enterTimer.start();
           }
       }
   }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:49,代码来源:ToolTipManagerEx.java

示例5: addAsFrame

import javax.swing.JComponent; //导入方法依赖的package包/类
/**
 * Adds a component on this Canvas inside a frame.
 *
 * @param comp The component to add to the canvas.
 * @param toolBox Should be set to true if the resulting frame is
 *     used as a toolbox (that is: it should not be counted as a
 *     frame).
 * @param popupPosition A preferred {@code PopupPosition}.
 * @param resizable Whether this component can be resized.
 * @return The {@code JInternalFrame} that was created and added.
 */
private JInternalFrame addAsFrame(JComponent comp, boolean toolBox,
                                  PopupPosition popupPosition,
                                  boolean resizable) {
    final int FRAME_EMPTY_SPACE = 60;

    final JInternalFrame f = (toolBox) ? new ToolBoxFrame()
        : new JInternalFrame();
    if (f.getContentPane() instanceof JComponent) {
        JComponent c = (JComponent) f.getContentPane();
        c.setOpaque(false);
        c.setBorder(null);
    }

    if (comp.getBorder() != null) {
        if (comp.getBorder() instanceof EmptyBorder) {
            f.setBorder(Utility.blankBorder(10, 10, 10, 10));
        } else {
            f.setBorder(comp.getBorder());
            comp.setBorder(Utility.blankBorder(5, 5, 5, 5));
        }
    } else {
        f.setBorder(null);
    }

    final FrameMotionListener fml = new FrameMotionListener(f);
    comp.addMouseMotionListener(fml);
    comp.addMouseListener(fml);
    if (f.getUI() instanceof BasicInternalFrameUI) {
        BasicInternalFrameUI biu = (BasicInternalFrameUI) f.getUI();
        biu.setNorthPane(null);
        biu.setSouthPane(null);
        biu.setWestPane(null);
        biu.setEastPane(null);
    }

    f.getContentPane().add(comp);
    f.setOpaque(false);
    f.pack();
    int width = f.getWidth();
    int height = f.getHeight();
    if (width > getWidth() - FRAME_EMPTY_SPACE) {
        width = Math.min(width, getWidth());
    }
    if (height > getHeight() - FRAME_EMPTY_SPACE) {
        height = Math.min(height, getHeight());
    }
    f.setSize(width, height);
    Point p = chooseLocation(comp, width, height, popupPosition);
    f.setLocation(p);
    this.add(f, MODAL_LAYER);
    f.setName(comp.getClass().getSimpleName());

    f.setFrameIcon(null);
    f.setVisible(true);
    f.setResizable(resizable);
    try {
        f.setSelected(true);
    } catch (java.beans.PropertyVetoException e) {}

    return f;
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:73,代码来源:Canvas.java


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