This week's book giveaway is in the Open Source forum.
We're giving away four copies of RabbitMQ in Depth and have Gavin Roy on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Display message in a JTextField Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of RabbitMQ in Depth this week in the Open Source forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Display message in a JTextField" Watch "Display message in a JTextField" New topic

Display message in a JTextField

Adam Henson

Joined: Dec 04, 2003
Posts: 1
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?
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24189

In an ActionListener registered with the JButton, call setText("The String") on the JTextField.

[Jess in Action][AskingGoodQuestions]
I agree. Here's the link:
subject: Display message in a JTextField