• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to get eventSource ??  RSS feed

 
Pratik Khetia
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi..I am attaching buttons from the JButton array and I need to know the value of the button.
so if jArray[0] = new JButton("User1")
then when I right click on this I want the value "User1"
When I simply click on this I can get it by -
e.getActionCommand()
But in the MouseEvent it doesnt work..
So please let me know if there is any method for that or not..
thanks
Pratik
 
Jianfei Yang
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can call getSource() of MouseEvent and get the text of JButton from source object which trigger this event.
 
Pratik Khetia
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey - I did that using string manipulation but is there any direct method to get the text of the JButton ??

Thanks
Pratik Khetia
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!