Class MapBinder

java.lang.Object
se.datadosen.util.MapBinder

public class MapBinder extends Object
Utility class for synchronizing a Swing GUI with a Map object. Synchronization is performed when calling getMap() and syncUI(). Matching is done where the name of a map key corresponds to the name of a GUI element. Currently handles JText components, JCheckBox, JComboBox and JColorSelector
This is a successor to PropertyBinder that keeps the datatypes of component values instead of converting all to strings like PropertyBinder does Copyright (c) 2003, David Ekholm Datadosen
Since:
8.8.1
  • Constructor Details

    • MapBinder

      public MapBinder()
  • Method Details

    • getMap

      public static Map<String,Object> getMap(JComponentHolder jComponentHolder)
      Read properties from a UI.
      Parameters:
      jComponentHolder - object containing Swing type member variables/components
      Returns:
      A property object where the keys have the same names as the member components
    • getMap

      public static Map<String,Object> getMap(JComponentHolder jComponentHolder, Map<String,Object> existing)
      Read properties from a UI.
      Parameters:
      jComponentHolder - object containing Swing type member variables/components
      existing - Properties object to add properties to
      Returns:
      A property object where the keys have the same names as the member components
      Throws:
      RuntimeException
    • syncUI

      public static void syncUI(Map<String,Object> props, JComponentHolder jComponentHolder)
      Update a UI from a Map object.
      Parameters:
      props - Properties to pass to UI
      jComponentHolder - object containing Swing type member variables/components to be synchronized.
      Throws:
      RuntimeException
    • registerComponentBinder

      public static MapBinder.ComponentBinder registerComponentBinder(Class componentClass, MapBinder.ComponentBinder binder)
      Add support for other component types (subclasses of JComponent)
      Parameters:
      componentClass -
      binder -
      Returns:
      Since:
      8.4