Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS 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
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

TextField Population of Mouse Events?

 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HOW DO I POPULATE THE TextField txt WITH THE String msg, WHICH IS DEFINED FOR EACH EVENT
 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
There are 3 modifications needed in your code.
1.TextField txt = new TextField(); should appear outside the constructor.
2.setVisible(true); should appear after add(txt, BorderLayout.SOUTH);
3.Add this line to your paint() method.
txt.setText(msg);
After these modifications the code is running fine on my machine.
 
Vivek Nambiar
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Farid!
 
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Vivek
define a new method, something like
public void setText(String msg)
{
txt.setText(msg);
}
call this method from inside every listener method. Of course, you'll have to define the TextField object txt as a instance member, i.e., outside the constructor.
Regards
Sanjeev
 
His brain is the size of a cherry pit! About the size of this ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic