Class PropertyBinder

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

public class PropertyBinder
extends java.lang.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
  • Nested Class Summary

    Nested Classes 
    Modifier and Type Class Description
    static interface  PropertyBinder.ComponentBinder
    Add support for other component types
  • Constructor Summary

    Constructors 
    Constructor Description
    PropertyBinder()  
  • Method Summary

    Modifier and Type Method Description
    static java.util.Properties getProperties​(JComponentHolder jComponentHolder)
    Read properties from a UI.
    static <T extends java.util.Map>
    T
    getProperties​(JComponentHolder jComponentHolder, T existing)
    Read properties from a UI.
    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)
    static PropertyBinder.ComponentBinder registerComponentBinder​(java.lang.Class componentClass, PropertyBinder.ComponentBinder binder)
    Add support for other component types (subclasses of JComponent)
    static void syncUI​(java.util.Map props, JComponentHolder jComponentHolder)
    Update a UI from a Map object.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • getProperties

      public static java.util.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 java.util.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:
      java.lang.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​(java.util.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:
      java.lang.RuntimeException
    • registerComponentBinder

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