Class JCBHandle<T>

java.lang.Object
jmri.util.swing.JCBHandle<T>
Type Parameters:
T - the class accepted by the JComboBox

public class JCBHandle<T> extends 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
     
    (package private) String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create a handle without a handled object, just a display label.
    Create a handle with a handled object.
  • Method Summary

    Modifier and Type
    Method
    Description
    Retrieve the handled object for this handle
    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
  • Field Details

  • Constructor Details

    • JCBHandle

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

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

    • toString

      public String toString()
      Display the handled item, or if there isn't one, the null-case label.
      Overrides:
      toString in class 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