當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。