Class ContextMenuBinder

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

public class ContextMenuBinder extends Object implements ControlBinder
Binds the textProperty of MenuItems inside a ContextMenu to language keys.

This binder checks whether a given control is an instance of ContextMenu and binds the text of its MenuItems using the provided key as a prefix. Each item's key is expected to be in the format prefix.itemId.

For example, if the prefix is fileMenu and a MenuItem has an ID of open, the full key will be fileMenu.open.

Since:
1.1.0
Author:
alan
  • Constructor Details

    • ContextMenuBinder

      public ContextMenuBinder()
  • Method Details

    • supports

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

      public void bind(Object control, String key)
      Binds the textProperty of all MenuItems inside the ContextMenu to language keys based on their IDs.
      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