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