• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Javafx TextField on edit event

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am Trying to use TextField in javafx. The scenario is I have list view populated with specific objects and edit button to edit the object associated with list cell of list view. When I click on edit button it redirects me to a pane with editing feature when I can edit the name of that object and save it using save button. So I have to put validation on save button to make it enable and disable . If I edit the name in text field then it should enable the save button other wise it should remains disabled. I have tried using different methods on text fields as below.

textField.textPorperty.addListener(listener -> {
//Logic to enable disable save button
});
As I am using list view, this listener gives me old value as previously edited object which does not satisfy my condition. I can not use

`textField.focusedProperty().addListener((observableValue, oldValue, newValue) -> {});`
as It does not give me expected behavior.

Can anyone help me to solve this issue?
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sudarshan,

Why don't you use one key pressed listener in the textfield in order to enable/disable the button?

Regards,
Luis
 
Rancher
Posts: 387
30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try this sample and see if anything in it does what you are looking for.
The sample implements a couple of different methods of providing editing functions.
One is a label, separate text field to edit the label and a save button to copy the edited text to the label (which I think is as you describe in your question).
The other editing method is a toggle button next to a text field which is initially read-only and styled to look like a label. When the button is toggled, the text field becomes editable and styled like a normal text field. Once the editing is complete by the user pressing enter or pressing the toggle button again to de-select it, the text field is styled to look like a label again.

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic