JavaFX properties look like this: StringPrroperty nameProperty = new SimpleStringProperty();
public String getName() { return nameProperty.get(); } public void setName(String name) { nameProperty.set(name); } public StringProperty nameProperty() { return nameProperty; } There's also a lazy version that won't create the actual property until it's used. StringPrroperty nameProperty; public String getName() { if (nameProperty == null) { return null; } else { return nameProperty.get(); } } public void setName(String name) { if (nameProperty == null) { nameProperty = new SimpleStringProperty(); } nameProperty.set(name); } public StringProperty nameProperty() { if (nameProperty == null) { nameProperty = new SimpleStringProperty(); } return nameProperty; } Finally, there's this version that delays creating a property until it's legitimately needed. This is nice if you're doing a bunch of Swing/JavaFX crossover stuff. No need for all the properties if the bean is being used in, say, a Swing form or table. Also nice for raw loading of beans from a DB for a report. JavaFX properties are a bit heavy. But the bean code is just a bit much. String _name; StringProperty nameProperty; public String getName() { if (nameProperty != null) { return nameProperty.get(); } else { return _name; } } public void setName(String name) { if (nameProperty != null) { nameProperty.set(name); } else { _name = name; } } public StringProperty nameProperty() { if (nameProperty == null) { nameProperty = new SimpleProperty(_name); } return nameProperty; } I just use the first, easy style in my work. I'm not working with volumes where the properties have been an issue. Netbeans has never had JavaFX property support that I know of. Even Lombok does not have support for FX style properties. Myself, I've been just cutting and pasting into ChatGPT when I need them in bulk. "The ultimate wizard". I love JavaFX properties, they're super powerful. Regards, Will Hartung On Tue, May 7, 2024 at 5:19 AM Sean Carrick <s...@pekinsoft.com> wrote: > PavelTurk, > > Actually, the only difference between the getters/setters in your two > messages are the content of the getters/setters and the parameter to the > setter. NB gives you the skeleton, which you then edit to your needs... > > Once you insert the getters/setters through the Source...Insert Code > (Alt+Insert), you end up with: > > public StringProperty getTest() { > return test; > } > > public void setTest(StringProperty test) { > this.test = test; > } > > With those skeletons in place, you edit them to fit your needs: > > public String getTest() { > return test.get(); > } > > public void setTest(String test) { > test.set(test); > } > > The code entered by the insert code command is editable, unlike when doing > visual development in Matisse (which is *actually editable*, if you know > how). NB cannot know everything that you need, but does its best to aide > you in not needing to manually type so much boiler-plate code. Once the > boiler-plate is in place, it is up to the developer to edit the default > code to fit their needs. > > I hope this helps you out. > > Sincerely, > > Sean Carrick > Owner - PekinSOFT Systems > s...@pekinsoft.com > (309) 989-0672 > > > On Tue, May 7, 2024 at 6:56 AM PavelTurk <pavelturk2...@gmail.com> wrote: > >> Hi Tom, >> >> Thank you for your reply. But I think you didn't pay attention to my >> example. Please, read it and you will understand that it is >> only about JavaFX properties. To make it clear, this is NOT what I need: >> >> public StringProperty getTest() { >> return test; >> } >> >> public void setTest(StringProperty test) { >> this.test = test; >> } >> >> Best regards, Pavel >> >> >> On 5/7/24 12:17 PM, Thomas Wolf wrote: >> > The solution doesn’t really have anything to do with Java FX. Put your >> cursor where you want to put the getter/setter methods and then right-click >> menu->Insert Code… and pick creation of getter/setter methods. >> > >> > Tom >> > >> >> On May 7, 2024, at 7:50 AM, PavelTurk <pavelturk2...@gmail.com> wrote: >> >> >> >> Hello all, >> >> >> >> Could anyone say how create property/getter/setter methods for JavaFX >> property? >> >> >> >> For example, if I have: >> >> >> >> private StringProperty test = new SimpleStringProperty(); >> >> >> >> I want NB to generate: >> >> >> >> public StringProperty testProperty() { >> >> return this.test; >> >> } >> >> >> >> public String getTest() { >> >> return this.test.get(); >> >> } >> >> >> >> public void setTest(String test) { >> >> this.test.set(test); >> >> } >> >> >> >> I installed JavaFX plugin but I can't find how to do it. I tried Alt + >> INS -> Add property but it seems that it can't do that. >> >> >> >> Best regards, Pavel >> >> >> >> --------------------------------------------------------------------- >> >> To unsubscribe, e-mail: users-unsubscr...@netbeans.apache.org >> >> For additional commands, e-mail: users-h...@netbeans.apache.org >> >> >> >> For further information about the NetBeans mailing lists, visit: >> >> https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists >> >> >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: users-unsubscr...@netbeans.apache.org >> For additional commands, e-mail: users-h...@netbeans.apache.org >> >> For further information about the NetBeans mailing lists, visit: >> https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists >> >>