• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to set the value of a JTextArea  RSS feed

 
Ramesh Balasubramanian
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a JList and JTextArea. When I choose a value in my ListBox it must automatically change my JTextArea value. This is
not happening!!!. I have pasted my code. Can anyone please look into and find out the bug.
 
deekasha gunwant
Ranch Hand
Posts: 396
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi ramesh,
the only problem in your code lies where u r adding the mouseListener to the List.
***************************************************
testmenu mouseListener = new testmenu();
LeftList.addMouseListener(mouseListener);
*****************************************************
u replace above two lines in ur code by one line
LeftList.addMouseListener(this);
Explanation--
---------------
in ur case u have created a new Object mouseListener (remember this mouseListener is having all RightTextarea as well as Left List) so when the method mouseClicked is called is called it changes the TextArea of the new object which is not visible to u.
in correct version we r using 'this' as the mouseListener. so when the setText method is invoked it changes the text of the text area that is visible to u.
hope this is clear
if not then do post ur confusion
deekasha

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!