Class LabeledBinder

java.lang.Object
io.github.snoopy137.languagemanager.binding.LabeledBinder
All Implemented Interfaces:
ControlBinder

public class LabeledBinder extends Object implements ControlBinder
Binds the textProperty of Labeled controls (e.g., Label, Button, CheckBox) to language keys.

This binder checks whether a given control is an instance of Labeled and binds its text to the language bundle using the provided key.

If the key is not found in the bundle, the current text is used as default.
Since:
1.1.0
Author:
alan
  • Constructor Details

    • LabeledBinder

      public LabeledBinder()
  • Method Details

    • supports

      public boolean supports(Object control)
      Returns true if the control is a Labeled.
      Specified by:
      supports in interface ControlBinder
      Parameters:
      control - the control to check
      Returns:
      true if the control is a Labeled instance, otherwise false
    • bind

      public void bind(Object control, String key)
      Binds the textProperty of the Labeled control to the given language key.

      If the key is not present in the language bundle, the current text of the control will be used as the default.

      Specified by:
      bind in interface ControlBinder
      Parameters:
      control - the control to bind
      key - the language key used to retrieve localized text from the resource bundle