TextField Document model

Mark Claassen markclaassenx at gmail.com
Mon Oct 22 07:01:10 PDT 2012

Alright, so Suggestion 1 had mutable content, but not allowing unrestricted

Suggestion 1: (possibility)
Add method in TextField public void setContent(TextFieldContent c);

public class TextFieldContent {
    public void delete(int start, int end, boolean notifyListeners) {
    public void insert(int index, String s, boolean notifyListeners) {
    public final String get(int start, int end) {
    final int length() {

> my strong preference is for option a (introduce a callback).

Suggestion 2: (possibility)
public interface ContentFilter
    public void onDelete(Content content, TextInputControl control, int
start, int end, boolean notifyListeners) {
    public void onInsert(Content content, TextInputControl control, int
index, String s, boolean notifyListeners) {

I added the TextInputControl to the list of parameters so that cursor
manipulation could be done.  The above specification would also require the
user to call content.delete() and content.insert() for anything to be
changed.  I thought about using boolean return values to signify whether or
not the input was already handled or not, but that would just force a user
to know how to used the booleans.  This seemed nicer to me.

This would allow I lot of power.
* It has the safety of calling the insert and delete models on the rigorous
implementation of Content
* Allows the content to be replaced (if appropriate) at each event.
* Allows for the Content variable to be final

> This approach works well, and it also looks great on our 'number of
controls' fact sheet :-)
I agree that having several well named controls is a good idea.  It makes
the bar a lot lower for newbies... which I guess we all area right now!

I would be interested in taking a stab at the FormattedTextField control.
What are your feelings for how you think it should work?


More information about the openjfx-dev mailing list