Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Display message in a JTextField  RSS feed

 
Adam Henson
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I allocate a text string to a JTextField?
I need a message to be displayed in the field when a JButton on the pane is clicked.. What is the best way of doing this?
Thanks
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In an ActionListener registered with the JButton, call setText("The String") on the JTextField.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!