Class JCBHandle<T>

  • Type Parameters:
    T - the class accepted by the JComboBox

    public class JCBHandle<T>
    extends java.lang.Object
    Wrap an object for easier null handling in a JComboBox. ("JCB" refers to JComboBox) Define a JComboBox<JCBHandle<Foo>>, then fill it with a new JCBHandle("None string") and your new JCBHandle(foo) entries.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) T item  
      (package private) java.lang.String label  
    • Constructor Summary

      Constructors 
      Constructor Description
      JCBHandle​(java.lang.String l)
      Create a handle without a handled object, just a display label.
      JCBHandle​(T t)
      Create a handle with a handled object.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      T item()
      Retrieve the handled object for this handle
      java.lang.String toString()
      Display the handled item, or if there isn't one, the null-case label.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • JCBHandle

        public JCBHandle​(T t)
        Create a handle with a handled object.
        Parameters:
        t - the class accepted by the JComboBox
      • JCBHandle

        public JCBHandle​(java.lang.String l)
        Create a handle without a handled object, just a display label.
        Parameters:
        l - label for handle
    • Method Detail

      • toString

        public java.lang.String toString()
        Display the handled item, or if there isn't one, the null-case label.
        Overrides:
        toString in class java.lang.Object
        Returns:
        the item's String representation or the default label
      • item

        public T item()
        Retrieve the handled object for this handle
        Returns:
        the object