B4J Library TextField As Label

This one was born out of frustration that in Javafx, you can't make a label's text selectable. This is a Textfield, that is styled as a label. with the added bonus that you can click the label to edit the text (which can be disabled) and would be useful to use in a data table or list where you may want to edit the field.

1693391024536.png
1693391086251.png
1693391107526.png

You can also make the TextfieldAsLabel focus traversable (or not) and match the left padding to a Textfield (left padding = 9) or a label (left padding = 0).

1693390780372.png

I have delegated the events for a Textfield, but not all of them from a label. They can easily be added if required.

There is a small CSS file called textfieldlabel.css that is required and is in the project and the b4xlib. This should be added to the Stylesheets on a Form or a Pane in the appropriate place.

There are no external dependencies.

Enjoy.
 

Attachments

  • TextFieldAsLabel.zip
    5.7 KB · Views: 83
  • TextFieldAsLabel-b4xlib.b4xlib
    2.3 KB · Views: 94
Last edited:
Top