This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin 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.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!