Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Swing / AWT / SWT and the fly likes JTextField changes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTextField changes" Watch "JTextField changes" New topic
Author

JTextField changes

Nadinha Jovan
Greenhorn

Joined: Feb 13, 2004
Posts: 6
I have a JTextField and a JButton. The user can either type the text in the text field or he can click the button and select the folder, whose name will be then entered as the text of the text field using setText method. In either one of the two cases I want to set a variable _userSetResultFolder = true.
However, there is also another text field in the panel that will set the result folder text field if it is not set by the user (_userSetResultFolder = false), to the value of this folder + /results, in this case of course I want _userSetResultFolder to remain false.

How can I ensure that even when the user types into the result folder text field rather than using the result folder button, the _userSetResultFolder gets set to true.

Thanks.
Darrin Smith
Ranch Hand

Joined: Aug 04, 2003
Posts: 276
Set up a DocumentListener on the JTextField that you want set the variable. Use another DocumentListener (or don't set one) on the JTextField that you do not want to set the variable.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JTextField changes
 
Similar Threads
X and O game
JTable, JTextField and focus
Buttons...
keyboard action of my JButton
Problem with FOR loop..Need Help ASAP...