wood burning stoves 2.0*
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
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Display message in a JTextField" Watch "Display message in a JTextField" New topic
Author

Display message in a JTextField

Adam Henson
Greenhorn

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?
Thanks
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

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


[Jess in Action][AskingGoodQuestions]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Display message in a JTextField
 
Similar Threads
JOptionPane.showInputDialog to accept multiple inputs
How to disable selection in a JTextField?
altering a GUI object without triggering the listener
JTextField focus problem ( urgent !!!!!!)
form design