1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
| /*
* Created on 22 mai 2007
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package cassis.jCassis.gui.spectrum.util;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;
import javax.swing.JLabel;
import javax.swing.JPopupMenu;
/**
* @author tamisier
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class LineInfoLabel implements MouseMotionListener {
private transient JPopupMenu popup;
/**
* Constructor makes a new LineInfoPopup invisible.
*/
public LineInfoLabel()
{
super();
popup = new JPopupMenu();
}
/**
* Display the LineInfoPopup when MouseEvent occurs.
* @param event MouseEvent
* @param menuList Menu to display
*/
public void display(final double coordX, final double coordY, final JLabel identification)
{
popup.add(identification);
System.out.println("coordX : " + coordX);
System.out.println("coordY : " + coordY);
// popup.setLocation(Integer.parseInt(String.valueOf(coordX)), Integer.parseInt(String.valueOf(coordY)));
popup.setLocation(500,300);
popup.addMouseMotionListener(this);
popup.setVisible(true);
}
/* (non-Javadoc)
* @see java.awt.event.MouseMotionListener#mouseDragged(java.awt.event.MouseEvent)
*/
public void mouseDragged(MouseEvent e) {
// TODO Auto-generated method stub
System.out.println("e.getX() : " + e.getX());
popup.setLocation(e.getX() + popup.getLocationOnScreen().x , e.getY() + popup.getLocationOnScreen().y);
}
/* (non-Javadoc)
* @see java.awt.event.MouseMotionListener#mouseMoved(java.awt.event.MouseEvent)
*/
public void mouseMoved(MouseEvent e) {
// TODO Auto-generated method stub
}
} |
Partager