Sorry I looked at the screenshot and didn't properly read the title. That's
a validation X.
If you're using TextComponet in the onTop mode you can use action() with a
material font icon to clear the text and actionClick() to invoke
setText("").
You can implement it otherwise by using something like this:
TextField field = ...;
Border b = field.getUnselectedStyle().getBorder();
field.getAllStyles().setBorder(null);
Button clearButton.= ...;
clearButton.addActionListener(e -> {
field.stopEditing();
field.setText("");
});
Container clearable = BorderLayout.centerEastWest(field, clearButton, null);
clearable.getUnselectedStyle().setBorder(b);
Notice I could have used a layered layout to place the button on top but I
find this approach to be more reliable.
--
You received this message because you are subscribed to the Google Groups
"CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/codenameone-discussions/3477205e-3aad-49f6-8605-ebca2ba0f8f8%40googlegroups.com.