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.


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).


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: 195
  • TextFieldAsLabel-b4xlib.b4xlib
    2.3 KB · Views: 198
Last edited:
Cookies are required to use this site. You must accept them to continue using the site. Learn more…