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


Java MouseMotionAdapter类代码示例

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


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

示例1: createToolTip

import java.awt.event.MouseMotionAdapter; //导入依赖的package包/类
@Override
public JToolTip createToolTip() {
    JToolTip t = toolTip;
    toolTip = null;
    if (t != null) {
        t.addMouseMotionListener(new MouseMotionAdapter() { // #233642

            boolean initialized = false;

            @Override
            public void mouseMoved(MouseEvent e) {
                if (!initialized) {
                    initialized = true; // ignore the first event
                } else {
                    // hide the tooltip if mouse moves over it
                    ToolTipManager.sharedInstance().mousePressed(e);
                }
            }
        });
        return t;
    } else {
        return super.createToolTip();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:Outline.java

示例2: PaintPanel

import java.awt.event.MouseMotionAdapter; //导入依赖的package包/类
public PaintPanel()
{
   // handle frame mouse motion event
   addMouseMotionListener(
      new MouseMotionAdapter() // anonymous inner class
      {  
         // store drag coordinates and repaint
         @Override
         public void mouseDragged(MouseEvent event)
         {
            points.add(event.getPoint());
            repaint(); // repaint JFrame
         } 
      } 
   ); 
}
 
开发者ID:cleitonferreira,项目名称:LivroJavaComoProgramar10Edicao,代码行数:17,代码来源:PaintPanel.java

示例3: initAndShowUI

import java.awt.event.MouseMotionAdapter; //导入依赖的package包/类
private static void initAndShowUI() {
    popupMenu = new JPopupMenu();
    for (int i = 0; i < 100; i++) {
        JRadioButtonMenuItem item = new JRadioButtonMenuItem(" Test " + i);
        item.addMouseMotionListener(new MouseMotionAdapter() {
            @Override
            public void mouseMoved(MouseEvent e) {
                passed = true;
            }
        });
        popupMenu.add(item);
    }

    frame = new JFrame();
    screenBounds.set(getScreenBounds());
    frame.setBounds(screenBounds.get());
    frame.setVisible(true);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:19,代码来源:bug7154841.java

示例4: CustomTreeRenderer

import java.awt.event.MouseMotionAdapter; //导入依赖的package包/类
public CustomTreeRenderer() {
    setOpaque(true);
    //setBackgroundNonSelectionColor(tree.getBackground());
    tree.addMouseMotionListener(new MouseMotionAdapter() {

        @Override
        public void mouseMoved(MouseEvent me) {
            TreePath treePath = tree.getPathForLocation(me.getX(), me.getY());
            Object obj;
            if (treePath != null) {
                obj = treePath.getLastPathComponent();
            } else {
                obj = null;
            }
            if (obj != lastNode) {
                lastNode = obj;
                tree.repaint();
            }
        }
    });
}
 
开发者ID:bcgov,项目名称:sbc-qsystem,代码行数:22,代码来源:JTreeComboBox.java

示例5: setup

import java.awt.event.MouseMotionAdapter; //导入依赖的package包/类
/** Install listeners during construction that are unique for the AutocompleteTextField.
 */
private void setup() {
	suggestionList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	popup.add(scrollPane);
	suggestionList.setFixedCellHeight(20);
	suggestionList.setFocusable(false);
	scrollPane.setFocusable(false);
	popup.setFocusable(false);
	suggestionList.addMouseMotionListener(new MouseMotionAdapter() {
		@Override
		public void mouseMoved(MouseEvent e) {
			int i = suggestionList.getUI().locationToIndex(suggestionList, e.getPoint());
			getModel().setSuggestions(model.suggestions, model.selectedIndex, i);
		}
	});
	
	getDocument().addDocumentListener(docListener);
	addKeyListener(keyListener);
	model.addChangeListener(modelListener);
	suggestionList.addListSelectionListener(listListener);
}
 
开发者ID:mickleness,项目名称:pumpernickel,代码行数:23,代码来源:AutocompleteTextField.java

示例6: getSlider

import java.awt.event.MouseMotionAdapter; //导入依赖的package包/类
public JSlider getSlider(int min, int max, int value) {
        JSlider slider = new JSlider(JSlider.HORIZONTAL, min, max, value);
        slider.setMajorTickSpacing(10);
        slider.setMinorTickSpacing(1);
//        slider.setPaintLabels(true);
//        slider.setUI(new WindowsSliderUI(slider));
        slider.setForeground(AppThemeColor.TEXT_DEFAULT);
        slider.setFont(REGULAR_FONT.deriveFont(15f));
        slider.setRequestFocusEnabled(false);
        slider.addMouseMotionListener(new MouseMotionAdapter() {
            @Override
            public void mouseDragged(MouseEvent e) {
                slider.getParent().repaint();
            }
        });
        slider.setBackground(AppThemeColor.FRAME);
        return slider;
    }
 
开发者ID:Exslims,项目名称:MercuryTrade,代码行数:19,代码来源:ComponentsFactory.java

示例7: createWindow

import java.awt.event.MouseMotionAdapter; //导入依赖的package包/类
/**
 * Create the Window for the given alignment and
 * 
 * @param comp
 *            father component
 * @param alignment
 *            algenment
 * @param point
 *            location point
 * @return the created window
 */
protected Window createWindow(Component comp, int alignment, Point point) {
	JToolBar bar = getToolBar(alignment);
	if (bar == null) {
		return null;
	}
	final JDialog dialog = new JDialog(JOptionPane.getFrameForComponent(comp));
	dialog.addMouseMotionListener(new MouseMotionAdapter() {

		public void mouseMoved(MouseEvent e) {
			if (!dialog.hasFocus())
				dialog.requestFocusInWindow();
		}

	});
	dialog.setUndecorated(true);
	dialog.setLayout(new BorderLayout());
	dialog.add(bar);
	dialog.pack();

	Point loc = adujstPoint(point);
	SwingUtilities.convertPointToScreen(loc, comp);
	dialog.setLocation(loc);
	return dialog;
}
 
开发者ID:iig-uni-freiburg,项目名称:SWAT20,代码行数:36,代码来源:WorkbenchPopupToolBar.java

示例8: setOnClickAction

import java.awt.event.MouseMotionAdapter; //导入依赖的package包/类
public void setOnClickAction(Runnable action){
    super.setOnClickAction(action);
    
    list.addMouseMotionListener(new MouseMotionAdapter() {

        @Override
        public void mouseMoved(java.awt.event.MouseEvent e) {
            JList l = (JList)e.getSource();
            ListModel m = l.getModel();
            int index = l.locationToIndex(e.getPoint());
            if (index > -1) {
                Requirement req = ((Presenter_Requirement) m.getElementAt(index)).getRequirement();
                String tooltip = (req != null) ? req.getTitle() + "<br>" + req.getDescription() : "";
                l.setToolTipText("<html><p>" + tooltip + "</p></html>");
            }
        }
    });
}
 
开发者ID:AMOSTeam3,项目名称:amos-ss15-proj3,代码行数:19,代码来源:Requirement_ElementHandler.java

示例9: SequenceModificationPanel

import java.awt.event.MouseMotionAdapter; //导入依赖的package包/类
/**
 * Creates a new SequenceFragmentationPanel.
 *
 * @param aSequence String with the Modified Sequence of a peptide
 * identification.
 * @param profiles ArrayList with the modification profiles.
 * @param boolModifiedSequence boolean describing the sequence. This
 * constructor can be used to enter a ModifiedSequence or a normal sequence.
 * @param score1Name the name of the score above of the sequence
 * @param score2Name the name of the score under the sequence
 * @throws java.awt.HeadlessException if GraphicsEnvironment.isHeadless()
 * returns true.
 * @see java.awt.GraphicsEnvironment#isHeadless
 * @see javax.swing.JComponent#getDefaultLocale
 */
public SequenceModificationPanel(String aSequence, ArrayList<ModificationProfile> profiles, boolean boolModifiedSequence, String score1Name, String score2Name) throws HeadlessException {
    super();
    this.score1Name = score1Name;
    this.score2Name = score2Name;
    isModifiedSequence = boolModifiedSequence;
    iSequenceComponents = parseSequenceIntoComponents(aSequence);
    this.profiles = profiles;
    this.setPreferredSize(new Dimension(estimateWidth(), estimateHeight()));
    this.setMaximumSize(new Dimension(estimateWidth(), estimateHeight()));

    fragmentIonRectangles = new HashMap<String, Rectangle>();

    addMouseMotionListener(new MouseMotionAdapter() {

        public void mouseMoved(MouseEvent me) {
            mouseMovedHandler(me);
        }
    });
}
 
开发者ID:compomics,项目名称:compomics-utilities,代码行数:35,代码来源:SequenceModificationPanel.java

示例10: MapView

import java.awt.event.MouseMotionAdapter; //导入依赖的package包/类
public MapView(SLMap map) {
    this.map = map;
    generateImage();

    addMouseMotionListener(new MouseMotionAdapter() {
        @Override
        public void mouseMoved(MouseEvent e) {
            mouseChanged();
        }
    });

    setLayout(new BorderLayout());
    this.imagePanel = new ImagePanel(mapImage);
    this.coordsLabel = new JLabel("Map Coordinates: ");
    add(imagePanel, BorderLayout.NORTH);
    add(coordsLabel, BorderLayout.SOUTH);
}
 
开发者ID:necr0potenc3,项目名称:uosl,代码行数:18,代码来源:MapView.java

示例11: ProgressGlassPane

import java.awt.event.MouseMotionAdapter; //导入依赖的package包/类
/** Creates a new instance of ProgressGlassPane */
public ProgressGlassPane() {
    // blocks all user input
    addMouseListener(new MouseAdapter() { });
    addMouseMotionListener(new MouseMotionAdapter() { });
    addKeyListener(new KeyAdapter() { });
    
    setFocusTraversalKeysEnabled(false);
    addComponentListener(new ComponentAdapter() {
        public void componentShown(ComponentEvent evt) {
            requestFocusInWindow();
        }
    });
    
    setBackground(Color.WHITE);
    setFont(new Font("Default", Font.BOLD, 16));
}
 
开发者ID:romainguy,项目名称:filthy-rich-clients,代码行数:18,代码来源:ProgressGlassPane.java

示例12: createWindow

import java.awt.event.MouseMotionAdapter; //导入依赖的package包/类
/**
 * Create the Window for the given alignment and
 * 
 * @param comp
 *            father component
 * @param alignment
 *            algenment
 * @param point
 *            location point
 * @return the created window
 */
protected Window createWindow(Component comp, int alignment, Point point) {
	JToolBar tlb = getToolBar(alignment);
	if (tlb == null) {
		return null;
	}
	final JDialog dlg = new JDialog(JOptionPane.getFrameForComponent(comp));
	dlg.addMouseMotionListener(new MouseMotionAdapter() {

		public void mouseMoved(MouseEvent e) {
			if (!dlg.hasFocus())
				dlg.requestFocusInWindow();
		}

	});
	dlg.setUndecorated(true);
	dlg.setLayout(new BorderLayout());
	dlg.add(tlb);
	dlg.pack();

	Point loc = adujstPoint(point);
	SwingUtilities.convertPointToScreen(loc, comp);
	dlg.setLocation(loc);
	return dlg;
}
 
开发者ID:iig-uni-freiburg,项目名称:WOLFGANG,代码行数:36,代码来源:PopupToolBar.java

示例13: GaragePanel

import java.awt.event.MouseMotionAdapter; //导入依赖的package包/类
GaragePanel(UI p) {
	super("src/hu/elte/txtuml/examples/garage/images/garage.jpg");
	parent = p;
	try {
		doorImg = ImageIO.read(new File("src/hu/elte/txtuml/examples/garage/images/door.jpg"));
		sirenImg1 = ImageIO.read(new File("src/hu/elte/txtuml/examples/garage/images/siren1.jpg"));
		sirenImg2 = ImageIO.read(new File("src/hu/elte/txtuml/examples/garage/images/siren2.jpg"));
	} catch (IOException e) {
		System.out.println("Error: Cannot load some image.");
	}
	addMouseMotionListener(new MouseMotionAdapter() {
		@Override
		public void mouseMoved(MouseEvent me) {
			Rectangle doorRect = new Rectangle(doorX, doorY, doorImg.getWidth(), doorImg.getHeight());
			if (doorRect.contains(me.getPoint())) {
				parent.control.motionSensorActivated();
				parent.control.alarmSensorActivated();
				setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
			} else {
				setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
			}
		}
	});
}
 
开发者ID:ELTE-Soft,项目名称:txtUML,代码行数:25,代码来源:UI.java

示例14: PaintPanel

import java.awt.event.MouseMotionAdapter; //导入依赖的package包/类
public PaintPanel()
{
   // handle frame mouse motion event
   addMouseMotionListener(

      new MouseMotionAdapter() // anonymous inner class
      {  
         // store drag coordinates and repaint
         public void mouseDragged( MouseEvent event )
         {
            if ( pointCount < points.length ) 
            {
               points[ pointCount ] = event.getPoint(); // find point
               pointCount++; // increment number of points in array
               repaint(); // repaint JFrame
            } // end if
         } // end method mouseDragged
      } // end anonymous inner class
   ); // end call to addMouseMotionListener
}
 
开发者ID:meisamhe,项目名称:GPLshared,代码行数:21,代码来源:PaintPanel.java

示例15: setMouseMotionListener

import java.awt.event.MouseMotionAdapter; //导入依赖的package包/类
private void setMouseMotionListener() {
    addMouseMotionListener(new MouseMotionAdapter() {
        @Override
        public void mouseMoved(final MouseEvent event) {
            final int cardIndex = getPermanentInfoIndexAt(event.getX(), event.getY());
            final boolean isCardChanged = (currentCardIndex != cardIndex);
            if (cardIndex >= 0) {
                if (isCardChanged) {
                    if (!CONFIG.isMouseWheelPopup() || viewer.getController().isPopupVisible()) {
                        showCardPopup(cardIndex);
                    }
                }
            } else {
                viewer.getController().hideInfo();
            }
            currentCardIndex = cardIndex;
            if (linkedScreenRectangles.size() > 1) {
                redrawCachedImage();
            }
        }
    });
}
 
开发者ID:magarena,项目名称:magarena,代码行数:23,代码来源:ImagePermanentViewer.java


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