• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

JTextField changes

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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've been selected to go to the moon! All thanks to this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic