Class PropertyBinder

java.lang.Object
se.datadosen.util.PropertyBinder

public class PropertyBinder extends Object
Utility class for synchronizing a Swing GUI with a Property object. Synchronization is performed when calling getProperties() and syncUI(). Matching is done where the name of a property corresponds to the name of a GUI element. Currently handles JText components, JCheckBox, JComboBox and JColorSelector
Copyright (c) 2003, David Ekholm Datadosen
  • Constructor Details

    • PropertyBinder

      public PropertyBinder()
  • Method Details

    • getProperties

      public static Properties getProperties(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
    • getProperties

      public static <T extends Map> T getProperties(JComponentHolder jComponentHolder, T existing)
      Read properties from a UI.
      Parameters:
      jComponentHolder - object containing Swing type member variables/components
      existing - Map<String, String> or Properties object to add properties to
      Returns:
      The same object passed as parameter, but filled in with values from jComponentHolder
      Throws:
      RuntimeException
    • isSynchingUI

      public static boolean isSynchingUI()
      Return true if we're currently synching a UI from a Map object on the same thread as calling thread (see syncUI(Map props, JComponentHolder jComponentHolder)
      Since:
      17.2
    • syncUI

      public static void syncUI(Map 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 PropertyBinder.ComponentBinder registerComponentBinder(Class componentClass, PropertyBinder.ComponentBinder binder)
      Add support for other component types (subclasses of JComponent)
      Parameters:
      componentClass -
      Since:
      8.4