/* * Created on 2004-8-30 * * To change the template for this generated file go to * Window>Preferences>Java>Code Generation>Code and Comments */ package test;/** * @author Administrator * * To change the template for this generated type comment go to * Window>Preferences>Java>Code Generation>Code and Comments */ import javax.swing.*; import java.awt.event.*;public class testApplet extends JApplet { ImageIcon img = null; JLabel lbl = null; int m_intXDown = 0, m_intYDown = 0;
public void init () { img = new ImageIcon ("D:/ProgramsExample/JavaExample/JavaPrj/bin/book_468158.jpg");//this.getCodeBase() + "book_468158.jpg"); JPanel pane =(JPanel)getContentPane(); lbl = new JLabel (img); pane.add(lbl);
void mouseMoved(MouseEvent e)
* Created on 2004-8-30
*
* To change the template for this generated file go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
package test;/**
* @author Administrator
*
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
import javax.swing.*;
import java.awt.event.*;public class testApplet extends JApplet
{
ImageIcon img = null;
JLabel lbl = null;
int m_intXDown = 0, m_intYDown = 0;
public void init ()
{
img = new ImageIcon ("D:/ProgramsExample/JavaExample/JavaPrj/bin/book_468158.jpg");//this.getCodeBase() + "book_468158.jpg");
JPanel pane =(JPanel)getContentPane();
lbl = new JLabel (img);
pane.add(lbl);
lbl.addMouseListener(new MouseListener ()
{
public void mousePressed(MouseEvent arg0)
{
// TODO Auto-generated method stub
m_intXDown = arg0.getX ();
m_intYDown = arg0.getY ();
}
public void mouseClicked(MouseEvent arg0)
{
// TODO Auto-generated method stub
} public void mouseReleased(MouseEvent arg0)
{
// TODO Auto-generated method stub
} public void mouseEntered(MouseEvent arg0)
{
// TODO Auto-generated method stub
} public void mouseExited(MouseEvent arg0)
{
// TODO Auto-generated method stub
}
});
//MouseMotionListener
lbl.addMouseMotionListener(new MouseMotionListener ()
{
public void mouseMoved(MouseEvent arg0)
{
lbl.move (lbl.LEFT + arg0.getX () - m_intXDown, lbl.TOP + arg0.getY () - m_intYDown);
System.out.println (m_intXDown);
} public void mouseDragged(MouseEvent arg0)
{
// TODO Auto-generated method stub
}
});
}
}