Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

liseners  RSS feed

 
rob armstrong
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a application that has graffics2D objects (shapes). I want to write events that respond when the mouse is on those objects. Not sure where to put the constructor and that...

private class MouseListen implements MouseListener{
public void mouseEntered(MouseEvent e){
if(e.getSource()==rectangleobject1)
{//whatever happens}


Where do I put the Constructor???
MouseListen ml=new MouseListen();
Thanks
roba
 
Cp Baherwani
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You add a mouse listener to a component. Say you want to listen for mouse events on your JPanel.



The mouseEntered method in MouseListen class will be called when the mouse enters myPanel.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!