Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

How to set the value of a JTextArea

 
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.
 
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

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic