Class ChoiceBoxBinder

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

public class ChoiceBoxBinder extends Object implements ControlBinder
A binder for ChoiceBox controls containing String items.

This binder updates the text of each item in the ChoiceBox by binding its language key to the appropriate entry in the resource bundle.

The keys are expected to follow the format: key.0, key.1, etc., based on the item's index in the list.

Example:
For a ChoiceBox<String> field named genderBox with 2 items, the expected keys in the resource bundle are genderBox.0, genderBox.1, etc.

This binder only works if all items are String instances.

Since:
1.1.0
Author:
alan
  • Constructor Details

    • ChoiceBoxBinder

      public ChoiceBoxBinder()
  • Method Details

    • supports

      public boolean supports(Object control)
      Checks if the given control is a ChoiceBox<String>.
      Specified by:
      supports in interface ControlBinder
      Parameters:
      control - the UI control to check
      Returns:
      true if the control is a ChoiceBox<String>, false otherwise
    • bind

      public void bind(Object control, String key)
      Binds each item in the ChoiceBox to a corresponding language key in the resource bundle.
      Specified by:
      bind in interface ControlBinder
      Parameters:
      control - the ChoiceBox to bind
      key - the base key used to look up each item (with index suffix)