• Post Reply Bookmark Topic Watch Topic
  • New Topic

JTextArea MouseListener  RSS feed

 
travis Haycock
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Should this code not work? all I'm trying to do is add an action listener to recognize a right click on my JTextArea so a jpopupmenu will appear with copy/paste options


userField = JtextArea and class is implementing MouseListener


 
Rob Camick
Ranch Hand
Posts: 2756
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out the section from the Swing tutorial on Bringing Up a Popup Menu for a working example.

Or even easier is to use the setComponentPopupMenu(...) method and it will do all the work for you.
 
travis Haycock
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey thank you for the response. I did something rather stupid... this application has 2000 lines so as you can imagine a little messy on my rough draft.. I already declared JTextArea = userField somewhere else so when I was trying to add a MouseListener again to the userField it would crash or not function properly , simply my error, the above worked for me and I found to be pretty simple all though I imagine there is a lot of different methods that work well or even better.



Thread Closed
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!