Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

TextField Population of Mouse Events?

 
Vivek Nambiar
Ranch Hand
Posts: 63
  • 0
  • 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
 
ali farid
Ranch Hand
Posts: 60
  • 0
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Farid!
 
Sanjeev Verma
Ranch Hand
Posts: 87
  • 0
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic